Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-22 Thread Vincent Pelletier
Le mardi 20 mars 2012 13:06:16, Sebastian Wain a écrit : It is a persistent queue with acknowledgment. The issue I see is the sync of the BTree between threads. Consumers/Producers get/put elements, one at a time, so before that operation can take place it will need to sync to have the most

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-20 Thread Vincent Pelletier
Le lundi 19 mars 2012 20:59:24, Sebastian Wain a écrit : Indeed I want to sync the same BTree between threads. I am adding persistence and acknowledgement to the Python queue. I don't understand what you mean by: - sync: ZODB is probably not a good backend to provide synchronisation as a

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-20 Thread Vincent Pelletier
Le lundi 19 mars 2012 21:49:11, Jim Fulton a écrit : sync should be deprecated. :) transaction.begin() is better. Off-topic: it is possible that calling transaction.begin() does not offer a most up-to-date view of the database. This is easy to notice when using another database concurrently

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-20 Thread Sebastian Wain
Indeed I want to sync the same BTree between threads. I am adding persistence and acknowledgement to the Python queue. I don't understand what you mean by: - sync: ZODB is probably not a good backend to provide synchronisation as a feature, ie it's not a lock server and does what it can to

[ZODB-Dev] How to update an object in a multithreading application?

2012-03-19 Thread Sebastian Wain
I am updating an item in a separated thread but when it finishes the new value is not updated in the same object in the main thread. In the example below root['counter'] starts in 0, is incremented in the new thread but it remains in 0 in the main thread. #!/usr/bin/python from

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-19 Thread Alan Runyan
I am updating an item in a separated thread but when it finishes the new value is not updated in the same object in the main thread. You need to call sync() on the connection object to see changes from another thread. http://zodb.readthedocs.org/en/latest/api.html#connections In the example

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-19 Thread Vincent Pelletier
Le lundi 19 mars 2012 18:57:53, Alan Runyan a écrit : if your increment a counter its best the counter be of type, BTrees.Length Depends on the usage. If generated numbers are intended to become unique identifiers, a BTree.Length is definitely not what he wants. Conflicts are good. In ZODB,

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-19 Thread Sebastian Wain
Le lundi 19 mars 2012 18:57:53, Alan Runyan a écrit : if your increment a counter its best the counter be of type, BTrees.Length Depends on the usage. If generated numbers are intended to become unique identifiers, a BTree.Length is definitely not what he wants. Conflicts are good. In

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-19 Thread Marius Gedminas
On Mon, Mar 19, 2012 at 02:04:34PM -0300, Sebastian Wain wrote: I am updating an item in a separated thread but when it finishes the new value is not updated in the same object in the main thread. In the example below root['counter'] starts in 0, is incremented in the new thread but it

Re: [ZODB-Dev] How to update an object in a multithreading application?

2012-03-19 Thread Jim Fulton
On Mon, Mar 19, 2012 at 4:36 PM, Marius Gedminas mar...@gedmin.as wrote: On Mon, Mar 19, 2012 at 02:04:34PM -0300, Sebastian Wain wrote: ... As Alan said, you need a connection.sync() here. I believe calling transaction.begin() again at this point would also do that (just remember that