[ZODB-Dev] Automating retry management

Jim Fulton jim at zope.com
Tue May 11 10:08:06 EDT 2010


On Tue, May 11, 2010 at 8:38 AM, Benji York <benji at zope.com> wrote:
> On Tue, May 11, 2010 at 7:34 AM, Jim Fulton <jim at zope.com> wrote:
>> [...] The best I've been
>> able to come up with is something like:
>>
>>    t = ZODB.transaction(3)
>>    while t.trying:
>>        with t:
>>            ... transaction body ...
>
> I think you could get this to work:
>
> for transaction in ZODB.retries(3):
>    with transaction:
>        ... transaction body ...
>
> ZODB.retries would return an iterator that would raise StopIteration on
> the next go-round if the previously yielded context manager exited
> without a ConflictError.

This is an improvement. It's still unsatisfying, but I don't think I'm going to
get satisfaction. :)

BTW, if I do something like this, I think I'll add a retry exception to
the transaction package and have ZODB.POSException.ConflictError
extend it so I can add the retry automation to the transaction package.

Jim

-- 
Jim Fulton


More information about the ZODB-Dev mailing list