Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24636

Re: retry many times decorator

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'bug.': 0.07; 'function,': 0.07; 'errors,': 0.09; 'retry': 0.09; 'timeout': 0.09; 'wrong,': 0.09; 'bug': 0.10; 'to:name:python- list': 0.15; 'buggy': 0.16; 'exponential': 0.16; 'fail,': 0.16; 'least,': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.17; 'fix': 0.17; 'thu,': 0.17; 'code.': 0.20; 'exceptions': 0.22; 'example': 0.23; 'errors': 0.23; 'to:2**1': 0.23; 'random': 0.24; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'leave': 0.26; 'coding': 0.27; "doesn't": 0.28; 'represent': 0.28; '+0100,': 0.29; "d'aprano": 0.29; 'steven': 0.29; 'things,': 0.29; 'probably': 0.29; "i'm": 0.29; 'maybe': 0.29; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'wrong': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'sometimes': 0.35; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'received:74.125': 0.36; "wasn't": 0.36; 'useful': 0.36; 'should': 0.36; 'problems': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'nothing': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'identify': 0.61; 'request.': 0.64; 'reasons,': 0.65; 'again?': 0.84; 'andrea': 0.84; 'decorate': 0.84; 'subject:times': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=BZrnJrD8jjxVdELkVSteNTUusAxh7NxOaQwNT8VR0WI=; b=hRGIE8njpJv36GLOeV/SeBGC0OFimMZqSjjib1EreQwCKfMnBITqv/3RUy6zX1KXSV LejLiR9e+2b0J0NdPlfa/LUNpS66OPcc72GQKd/Jrh8503EdZzCv1d1vWSSmasCgGoVV fhdInEaifnImAfsfjbmERjYjDDQttENQPmS7Gar1NV5cvXMUqwOeRDEhKGpc6KYVdQ2H 90Rmv2BsDwi9q8V4n+XbILKp6QQ1/ZhjFg7LCCSEmRenlLFpFraeNl+XAqohOpjN/W2U l18lrhAm3qFjus+u5KJikzBhP0Lj8TQ73ddK/RHeRIA1K41iAndD6sZvqRiZSM2CpYNc ij/w==
Date Thu, 28 Jun 2012 22:11:44 +0100
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120616 Thunderbird/13.0.1
MIME-Version 1.0
To Steven D'Aprano <steve+comp.lang.python@pearwood.info>, python-list <python-list@python.org>
Subject Re: retry many times decorator
References <CAF_E5JYVNQmf7yptnuarqV8=aVPaix5xQg-q9bFe3Cg8wwPNYg@mail.gmail.com> <4FEC8278.7020806@mrabarnett.plus.com> <mailman.1612.1340900799.4697.python-list@python.org> <4fec97d9$0$29978$c3e8da3$5496439d@news.astraweb.com>
In-Reply-To <4fec97d9$0$29978$c3e8da3$5496439d@news.astraweb.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1621.1340917948.4697.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1340917948 news.xs4all.nl 6910 [2001:888:2000:d::a6]:59512
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:24636

Show key headers only | View raw


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..

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: retry many times decorator andrea crotti <andrea.crotti.0@gmail.com> - 2012-06-28 17:26 +0100
  Re: retry many times decorator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-06-28 17:43 +0000
    Re: retry many times decorator Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-06-28 22:11 +0100
    Re: retry many times decorator andrea crotti <andrea.crotti.0@gmail.com> - 2012-06-29 09:53 +0100
      Re: retry many times decorator Justin Barber <barber.justin@gmail.com> - 2012-06-29 05:45 -0700
      Re: retry many times decorator Justin Barber <barber.justin@gmail.com> - 2012-06-29 05:45 -0700

csiph-web