Kenneth Miller wrote at 2008-1-17 15:03 -0600:
>I see in the user guide that it mentions that you need to have a connection
>instance per thread to allow multiple threads to access a particular FS.
>Does anyone have any simple example code on doing this?

News threads usually have a form like:

     import transaction
     from ZODB.POSException import ConflictError

     conn = db.open() # open a new ZODB connection
     root = conn.root()
     try:
       retry = True
       while retry:
         retry = False
         try:
           do_your_function(root)
           transaction.commit()
         except ConflictError:
           transaction.abort()
           retry = True # you may want to restrict the possible retry number
         except:
           transaction.abort()
           # you may want to log your exception in some way
           raise
     finally:
       conn.close()


-- 
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

Reply via email to