On 06/28/2012 06:43 PM, Steven D'Aprano wrote:
On Thu, 28 Jun 2012 17:26:36 +0100, andrea crotti wrote:


I disagree. If you make a coding error in your function, why do you think
it is useful to retry that buggy code over and over again? It's never
going to get less buggy unless you see the exception and fix the bug.

For any operation that you want to retry, identify the *temporary*
errors, catch them, and retry the request. *Permanent* errors should
immediately fail, without retrying. *Unexpected* errors should not be
caught, since they probably represent a bug in your code.

Ah well maybe I wasn't clear, but I'm not going to retry random things, I will only decorate the functions that I know for sure that could go wrong for temporary network problems.

For example they told me that sometimes mysql just doesn't respond in time for some reasons,
but there's nothing permanently wrong, so retrying is the best option..

It would be good of course, however, to catch the exceptions that are known to be permanent problems
in the function at least, and leave the retry as last resource..

Thanks for the idea of the exponential backoff, which is also a better name than timeout for the variable..
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to