Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose convenient API for verbose logging with args #21

Closed
bgreen-litl opened this issue Nov 18, 2016 · 5 comments
Closed

Expose convenient API for verbose logging with args #21

bgreen-litl opened this issue Nov 18, 2016 · 5 comments
Milestone

Comments

@bgreen-litl
Copy link
Member

bgreen-litl commented Nov 18, 2016

See related discussion in #16

@k-funk
Copy link

k-funk commented May 1, 2017

+1
I've put logging.getLogger('backoff').setLevel(logging.CRITICAL) into my application because I find the default logging to be too verbose.

def giveup_handler(details):
    raise Exception('Too many tries: {}'.format(details['tries']))

@backoff.on_predicate(backoff.expo, predicate_fn, max_tries=3, on_giveup=giveup_handler)
def get_item():
    pass

Somewhat Related:
Since the max_retries kwarg doesn't make the function actually raise an Exception, I have to write that silly def giveup_handler, but then the details still get logged even though I'm handling the giveup myself, which I find odd.

@bgreen-litl
Copy link
Member Author

bgreen-litl commented May 2, 2017

Hm for your second point, when max_tries is exhausted, the exception will be let through. Are you not seeing that?

>>> import backoff
>>> @backoff.on_exception(backoff.expo, Exception, max_tries=3)
... def foo():
...     raise Exception('foo')
...
>>> foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../backoff/backoff/_sync.py", line 141, in retry
    ret = target(*args, **kwargs)
  File "<stdin>", line 3, in foo
Exception: foo

@k-funk
Copy link

k-funk commented May 2, 2017

Not referring to my fn raising an exception. I'm mostly referring to the backoff decorator: it doesn't raise an exception when max_tries is reached, which seems to be by design. I just find this odd because it logs as if an exception was thrown (logging.error).

@bgreen-litl
Copy link
Member Author

Here is another vote for lower priority default logging for exceptions.
#33

@bgreen-litl
Copy link
Member Author

@k-funk I think I'm going to make regular retries (on_backoff) log as INFO rather than ERROR for 1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants