[Twisted-Python] Retrying function calls

Terry Jones terry at jon.es
Sun Nov 1 19:05:22 EST 2009

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 least not with the
kinds of usages I am imagining. If you decorate a function, it's done once
and for all. So anyone who calls the function gets the single
one-size-fits-all decorated behavior. I'd rather the behavior was left in
the hands of the caller. That's kind of the point: give the caller flexible
control over what happens if something goes wrong, including passing in
your custom failure handler, etc.

Maybe a hybrid approach would be more useful: write a function which,
passed a function, returns a retrying version of that function that returns
a deferred that fires when the original function has succeeded (or
ultimately failed). The result could then be passed around, called by
multiple pieces of code, etc. Hmmm...

Thanks again.


More information about the Twisted-Python mailing list