Victor Safronovich wrote at 2005-10-21 14:54 +0600: > ... > app = Zope.bobo_application() > try: > self.running = True > while self.running: > get_transaction().begin() > try: > scheduler = app.unrestrictedTraverse( self.scheduler_path ) > scheduler.dispatchEvents() > get_transaction().commit() > except Exception: > get_transaction().abort() > ... >But connection to the ZODB in the app object some times does`t see >modifications >from the others connections :(.
This is not surprising: The world changes for a single thread only at (its) transaction boundaries. Changes committed by other threads after the "commit/abort" above are not seen in this thread until it executed a new "commit/abort". Thus, in case "dispatchEvents" blocks for events, you may loose modifications. >This repaired in this way > ... > app = Zope.bobo_application() > try: > get_transaction().begin() > try: > scheduler = app.unrestrictedTraverse( self.scheduler_path ) > scheduler.dispatchEvents() > get_transaction().commit() > except Exception: > get_transaction().abort() Now, you will loose only those modifications happening after the "app = ...". You reduced the risk but can not yet be sure... > ... >But this create new ZODB-connection every time, is this bad or good? A single one would be a bit more efficient -- but you need not to care. -- Dieter _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev