[ZODB-Dev] Items committed in one thread not seen in another
thread?
Christian Robottom Reis
kiko at async.com.br
Wed Mar 9 13:11:14 EST 2005
On Wed, Mar 09, 2005 at 05:17:41PM +0000, Gwyn Evans wrote:
> _storage = FileStorage.FileStorage('crmRetryDb.fs')
> database = DB(_storage) # Common to multiple threads
>
> but the two threads have their individual 'root' instances, each
> obtained as below -
>
> dbConn = database.open() # Thread-specific
> root = dbConn.root()
>
> The persistance is done as below, where d = a dictionary -
>
> self.dbRoot[recId] = d
> get_transaction().commit()
>
> If I stop and restart the app, so I'd not starting with an empty DB,
> the second thread will find the entries that were persisted in the
> previous session, but new ones aren't seen (until a further restart,
> and so on!)
A thread has a local view of its object, and modifications made in other
threads are not visible "automatically": you need to call sync() on the
connection, or abort()/commit() a transaction.
Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331
More information about the ZODB-Dev
mailing list