This repository was archived by the owner on Aug 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
This repository was archived by the owner on Aug 8, 2025. It is now read-only.
Duplicate logging in some special cases #179
Copy link
Copy link
Open
Description
Python 3.10.5 (main, Jul 25 2022, 15:40:10) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
backoff==2.2.1
Run this example:
import sys
import backoff
import logging
logging.basicConfig()
retry_runtime_error = backoff.on_exception(
backoff.constant,
RuntimeError,
max_tries=2,
interval=0,
)
def func():
raise RuntimeError()
if __name__ == '__main__':
try:
retry_runtime_error(func)()
except RuntimeError:
pass
print('---------------', file=sys.stderr)
try:
retry_runtime_error(func)()
except RuntimeError:
pass
print('---------------', file=sys.stderr)
try:
retry_runtime_error(func)()
except RuntimeError:
passExpected output:
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
---------------
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
---------------
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
Actually output:
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
---------------
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
---------------
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
INFO:backoff:Backing off func(...) for 0.0s (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
ERROR:backoff:Giving up func(...) after 2 tries (RuntimeError)
It's because of nonlocal here:
Line 184 in a1e19d9
| nonlocal logger, on_success, on_backoff, on_giveup |
edgarrmondragon and alwavshumilin
Metadata
Metadata
Assignees
Labels
No labels