Chris Withers wrote:
Andrew McLean wrote:
Any advice gratefully received.


I'd suggested moving to a ZODB version new enough to have MVCC support, which will likely make your problem go away...

Chris

I'm using v3.6. Unless I'm missing something, it's the most recent stable version.

Since my first post I tried another approach. Namely creating (and using) a new connection instance in the thread that raised the ReadConflictError exception. It "seems" to work, but I would like to understand this a bit better.

class Downloader(threading.Thread):
   """Downloader class to download urls"""
   def __init__(self, id, taskQueue, resultQueue, db):
       self.id = id
       self.__taskQueue = taskQueue
       self.__resultQueue = resultQueue
       self.__db = db
       self.connect()
       threading.Thread.__init__(self)
   def connect(self):
       self.__results = self.__db.open().root()['done']
   def run(self):
       while 1:
           # Get task from the queue
           task = self.__taskQueue.get()
           if (task[1] == 1) or (not self.done(task)):
               # ...
               self.__resultQueue.put((task, result))
   def done(self, task):
       while 1:
           try:
               return self.__results.has_key(task)
           except ReadConflictError:
print "*** ReadConflictError raised: Generate new connection to database ***" self.connect()

_______________________________________________
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