Popular recipes tagged "retry" and "closure"http://code.activestate.com/recipes/tags/retry+closure/2012-07-24T09:51:48-07:00ActiveState Code RecipesA Python decorator that re-executes the function on condition (Python)
2012-07-24T09:51:48-07:00Chaobin Tang (唐超斌)http://code.activestate.com/recipes/users/4174076/http://code.activestate.com/recipes/578222-a-python-decorator-that-re-executes-the-function-o/
<p style="color: grey">
Python
recipe 578222
by <a href="/recipes/users/4174076/">Chaobin Tang (唐超斌)</a>
(<a href="/recipes/tags/closure/">closure</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/retry/">retry</a>).
Revision 3.
</p>
<p>Sometimes we want a function to be able to be retried automatically, such as a function that does networking trying to write/read data through a pre-established connection. Instead of writing try/except everywhere, a decorator would save much code and provide a single copy of code to do all the work.</p>