[ZODB-Dev] ConflictError?

Steve Alexander steve@cat-box.net
Thu, 26 Jul 2001 21:30:50 +0100


Chris Withers wrote:
> 
> ..that raises a python question:
> 
> Is it okay to do something like the following:
> 
> for x in y:
> 
>   get_transaction().begin()
>   ...do stuff with x...
>   try:
>     get_transaction().commit()
>   except ConflictError:
>     y.append(x)

I can't see a problem with that... except that you could get yourself 
into never-ending loops.

Perhaps you could keep a dict of keys_that_got_conflict_errors against 
the number of retries they've had, then check to see if that exceeds a 
reasonable number before re-appending your value to y.

--
Steve Alexander
Software Engineer
Cat-Box limited