Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
Hi Tim > Since this is a generator function, it will automatically raise > StopIteration once control-flow falls off the end of the function, so your > while-loop could just be written: Ah yes, thanks a lot. Terry ___ Twisted-Python mailing list Twist

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Tim Allen
On Sun, Nov 01, 2009 at 05:53:31PM +0100, Terry Jones wrote: > def simpleBackoffIterator(maxResults=10, maxDelay=5.0, now=True, > initDelay=0.01, incFunc=None): > assert maxResults > 0 > remaining = maxResults > delay = initDelay > incFunc = incFunc or part

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
Hi Blair > Looks pretty good. To streamline the usage and make the intent more > apparent from a brief glance at the header you might consider turning it > into a decorator, like Thanks for the suggestion & the pointer. I'd not seen that page. I don't think this is well suited to decorators, at

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Blair Bethwaite
Hi Terry, 2009/11/1 Terry Jones : > My questions are: Is this robust? Can/should it be improved?  Any criticism > of the code (especially wrt Twisted best practices) would be very welcome. Looks pretty good. To streamline the usage and make the intent more apparent from a brief glance at the hea

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
Following up on my own post: > When the backoff iterator finishes, the RetryingCall class gives up on > trying to get a non-error result from the function. In that case you just > get a StopIteration exception in the failure that start() deferred > returns (I was originally returning the original

[Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
These days I often find myself writing code to talk to services that are periodically briefly unavailable. An error of some kind occurs and the correct (and documented) action to take is just to retry the original call. Examples include using Amazon's S3 service and the Twitter API. In both of thes