On Mar 28, 2012, at 2:47 AM, Chris McDonough wrote:

> Not sure what you'd say there.. "a for loop has to be broken out of for the 
> for loop to not loop"? ;-)

I believe Thierry is talking about the issue I filed long time ago.

https://bugs.launchpad.net/transaction/+bug/724332

The way this feature is described in the docs, one expects that:

- it tries to commit up to N times in presence of conflict errors, but
- it leaves the loop after the first successful commit.
  (otherwise, if it succeeds in the attempt K, it commits N-K times)

Currently, one has to write the code in this manner:

        for tx_attempt in transaction.attempts(5):
            with tx_attempt as tx:
                # Do some work that tries to commit here
            # Workaround for unexpected behavior of `attempts` generator
            # in transaction-1.1.1 so we can break out after commit.
            if tx.status == 'Committed':
                break

I'm really not sure that checking tx.status is the *best* way to go, but it's 
one way that works.

Best regards,

        Zvezdan

_______________________________________________
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to