[ZODB-Dev] Items committed in one thread not seen in another thread?

Gwyn Evans gwyn.evans at gmail.com
Wed Mar 9 12:17:41 EST 2005


Hi,
  I'm having a problem with ZODB that's showing up as the above and
wondered if anyone's got any ideas or suggestions?

  I'm testing with FileStorage on WinXP, where I get some events into
my class which I try & forward over the network.  If I can't, I'm
persisting them using ZODB.  I also have a retry thread, which is
listening on a Queue, to which the main thread does a put().  When the
retry thread returns from it's Queue.get(), it sleeps for a bit then
tries to do a root.items(), but is finding nothing in the root().

I'm using a module-common DB instance - 

  _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!)

----
I'd also be interested is anyone's got any other suggestions.  The
basic requirement is to be able to persist dictionary instances in one
thread such that a second thread can iterate through them, potentially
removing entries while new ones are being added.

/Gwyn


More information about the ZODB-Dev mailing list