[ZODB-Dev] Problems with ReadConflictError

Andrew McLean andrew-zodb at andros.org.uk
Tue Aug 22 07:44:33 EDT 2006


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




More information about the ZODB-Dev mailing list