From: Ruslan Lutsenko Date: Mon, 14 Jan 2013 16:34:51 +0000 (+0100) Subject: Fix: UnboundLocalError: local variable 'fn_name' referenced before assignment X-Git-Tag: v0.2.23~260 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af1f1e91206a45dc17c488389626a72e3bf77d2d;p=tools%2Fpython-jenkinsapi.git Fix: UnboundLocalError: local variable 'fn_name' referenced before assignment --- diff --git a/jenkinsapi/utils/retry.py b/jenkinsapi/utils/retry.py index a9f1478..d39c684 100644 --- a/jenkinsapi/utils/retry.py +++ b/jenkinsapi/utils/retry.py @@ -29,17 +29,18 @@ def retry_function( tries, fn, *args, **kwargs ): except urllib2.HTTPError, e: if e.code == 404: raise - log.exception(e) except Exception, e: if type(e) in IGNORE_EXCEPTIONS: # Immediatly raise in some cases. raise - try: - fn_name = fn.__name__ - except AttributeError: - fn_name = "Anonymous Function" - log.exception(e) + try: + fn_name = fn.__name__ + except AttributeError: + fn_name = "Anonymous Function" + log.exception(e) + if attemptno == tries: + log.error( "%s failed at attempt %i, give up." % ( fn_name , attemptno ) ) + raise log.warn( "%s failed at attempt %i, trying again." % ( fn_name , attemptno ) ) time.sleep( DEFAULT_SLEEP_TIME ) - raise e