python-backoff 2.2.2rc1__py3-none-any.whl → 2.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backoff/_async.py +7 -8
- backoff/_common.py +2 -2
- backoff/_decorator.py +5 -5
- backoff/_sync.py +4 -6
- backoff/_wait_gen.py +7 -7
- backoff/types.py +1 -1
- {python_backoff-2.2.2rc1.dist-info → python_backoff-2.3.0.dist-info}/METADATA +5 -6
- python_backoff-2.3.0.dist-info/RECORD +14 -0
- {python_backoff-2.2.2rc1.dist-info → python_backoff-2.3.0.dist-info}/WHEEL +1 -1
- python_backoff-2.2.2rc1.dist-info/RECORD +0 -14
- {python_backoff-2.2.2rc1.dist-info → python_backoff-2.3.0.dist-info}/licenses/LICENSE +0 -0
backoff/_async.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# coding:utf-8
|
|
2
|
-
import datetime
|
|
3
|
-
import functools
|
|
4
2
|
import asyncio
|
|
3
|
+
import functools
|
|
5
4
|
import inspect
|
|
6
|
-
|
|
5
|
+
import time
|
|
7
6
|
|
|
8
|
-
from backoff._common import
|
|
7
|
+
from backoff._common import _init_wait_gen, _maybe_call, _next_wait
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def _ensure_coroutine(coro_or_func):
|
|
@@ -61,11 +60,11 @@ def retry_predicate(target, wait_gen, predicate,
|
|
|
61
60
|
max_time_value = _maybe_call(max_time)
|
|
62
61
|
|
|
63
62
|
tries = 0
|
|
64
|
-
start =
|
|
63
|
+
start = time.monotonic()
|
|
65
64
|
wait = _init_wait_gen(wait_gen, wait_gen_kwargs)
|
|
66
65
|
while True:
|
|
67
66
|
tries += 1
|
|
68
|
-
elapsed =
|
|
67
|
+
elapsed = time.monotonic() - start
|
|
69
68
|
details = {
|
|
70
69
|
"target": target,
|
|
71
70
|
"args": args,
|
|
@@ -135,11 +134,11 @@ def retry_exception(target, wait_gen, exception,
|
|
|
135
134
|
max_time_value = _maybe_call(max_time)
|
|
136
135
|
|
|
137
136
|
tries = 0
|
|
138
|
-
start =
|
|
137
|
+
start = time.monotonic()
|
|
139
138
|
wait = _init_wait_gen(wait_gen, wait_gen_kwargs)
|
|
140
139
|
while True:
|
|
141
140
|
tries += 1
|
|
142
|
-
elapsed =
|
|
141
|
+
elapsed = time.monotonic() - start
|
|
143
142
|
details = {
|
|
144
143
|
"target": target,
|
|
145
144
|
"args": args,
|
backoff/_common.py
CHANGED
|
@@ -65,14 +65,14 @@ def _prepare_logger(logger):
|
|
|
65
65
|
# Configure handler list with user specified handler and optionally
|
|
66
66
|
# with a default handler bound to the specified logger.
|
|
67
67
|
def _config_handlers(
|
|
68
|
-
user_handlers, *, default_handler=None, logger=None, log_level=None
|
|
68
|
+
user_handlers, *, default_handler=None, logger=None, log_level=None,
|
|
69
69
|
):
|
|
70
70
|
handlers = []
|
|
71
71
|
if logger is not None:
|
|
72
72
|
assert log_level is not None, "Log level is not specified"
|
|
73
73
|
# bind the specified logger to the default log handler
|
|
74
74
|
log_handler = functools.partial(
|
|
75
|
-
default_handler, logger=logger, log_level=log_level
|
|
75
|
+
default_handler, logger=logger, log_level=log_level,
|
|
76
76
|
)
|
|
77
77
|
handlers.append(log_handler)
|
|
78
78
|
|
backoff/_decorator.py
CHANGED
|
@@ -8,7 +8,7 @@ from backoff._common import (
|
|
|
8
8
|
_prepare_logger,
|
|
9
9
|
_config_handlers,
|
|
10
10
|
_log_backoff,
|
|
11
|
-
_log_giveup
|
|
11
|
+
_log_giveup,
|
|
12
12
|
)
|
|
13
13
|
from backoff._jitter import full_jitter
|
|
14
14
|
from backoff import _async, _sync
|
|
@@ -89,13 +89,13 @@ def on_predicate(wait_gen: _WaitGenerator,
|
|
|
89
89
|
on_backoff,
|
|
90
90
|
default_handler=_log_backoff,
|
|
91
91
|
logger=logger,
|
|
92
|
-
log_level=backoff_log_level
|
|
92
|
+
log_level=backoff_log_level,
|
|
93
93
|
)
|
|
94
94
|
on_giveup = _config_handlers(
|
|
95
95
|
on_giveup,
|
|
96
96
|
default_handler=_log_giveup,
|
|
97
97
|
logger=logger,
|
|
98
|
-
log_level=giveup_log_level
|
|
98
|
+
log_level=giveup_log_level,
|
|
99
99
|
)
|
|
100
100
|
|
|
101
101
|
if inspect.iscoroutinefunction(target):
|
|
@@ -113,7 +113,7 @@ def on_predicate(wait_gen: _WaitGenerator,
|
|
|
113
113
|
on_success=on_success,
|
|
114
114
|
on_backoff=on_backoff,
|
|
115
115
|
on_giveup=on_giveup,
|
|
116
|
-
wait_gen_kwargs=wait_gen_kwargs
|
|
116
|
+
wait_gen_kwargs=wait_gen_kwargs,
|
|
117
117
|
)
|
|
118
118
|
|
|
119
119
|
# Return a function which decorates a target with a retry loop.
|
|
@@ -215,7 +215,7 @@ def on_exception(wait_gen: _WaitGenerator,
|
|
|
215
215
|
on_backoff=on_backoff,
|
|
216
216
|
on_giveup=on_giveup,
|
|
217
217
|
raise_on_giveup=raise_on_giveup,
|
|
218
|
-
wait_gen_kwargs=wait_gen_kwargs
|
|
218
|
+
wait_gen_kwargs=wait_gen_kwargs,
|
|
219
219
|
)
|
|
220
220
|
|
|
221
221
|
# Return a function which decorates a target with a retry loop.
|
backoff/_sync.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# coding:utf-8
|
|
2
|
-
import datetime
|
|
3
2
|
import functools
|
|
4
3
|
import time
|
|
5
|
-
from datetime import timedelta
|
|
6
4
|
|
|
7
5
|
from backoff._common import (_init_wait_gen, _maybe_call, _next_wait)
|
|
8
6
|
|
|
@@ -32,11 +30,11 @@ def retry_predicate(target, wait_gen, predicate,
|
|
|
32
30
|
max_time_value = _maybe_call(max_time)
|
|
33
31
|
|
|
34
32
|
tries = 0
|
|
35
|
-
start =
|
|
33
|
+
start = time.monotonic()
|
|
36
34
|
wait = _init_wait_gen(wait_gen, wait_gen_kwargs)
|
|
37
35
|
while True:
|
|
38
36
|
tries += 1
|
|
39
|
-
elapsed =
|
|
37
|
+
elapsed = time.monotonic() - start
|
|
40
38
|
details = {
|
|
41
39
|
"target": target,
|
|
42
40
|
"args": args,
|
|
@@ -88,11 +86,11 @@ def retry_exception(target, wait_gen, exception,
|
|
|
88
86
|
max_time_value = _maybe_call(max_time)
|
|
89
87
|
|
|
90
88
|
tries = 0
|
|
91
|
-
start =
|
|
89
|
+
start = time.monotonic()
|
|
92
90
|
wait = _init_wait_gen(wait_gen, wait_gen_kwargs)
|
|
93
91
|
while True:
|
|
94
92
|
tries += 1
|
|
95
|
-
elapsed =
|
|
93
|
+
elapsed = time.monotonic() - start
|
|
96
94
|
details = {
|
|
97
95
|
"target": target,
|
|
98
96
|
"args": args,
|
backoff/_wait_gen.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing import Any, Callable, Generator, Iterable, Optional, Union
|
|
|
8
8
|
def expo(
|
|
9
9
|
base: float = 2,
|
|
10
10
|
factor: float = 1,
|
|
11
|
-
max_value: Optional[float] = None
|
|
11
|
+
max_value: Optional[float] = None,
|
|
12
12
|
) -> Generator[float, Any, None]:
|
|
13
13
|
|
|
14
14
|
"""Generator for exponential decay.
|
|
@@ -22,12 +22,12 @@ def expo(
|
|
|
22
22
|
"""
|
|
23
23
|
# Advance past initial .send() call
|
|
24
24
|
yield # type: ignore[misc]
|
|
25
|
-
|
|
25
|
+
base_n: float = 1
|
|
26
26
|
while True:
|
|
27
|
-
a = factor *
|
|
27
|
+
a = factor * base_n
|
|
28
28
|
if max_value is None or a < max_value:
|
|
29
29
|
yield a
|
|
30
|
-
|
|
30
|
+
base_n *= base
|
|
31
31
|
else:
|
|
32
32
|
yield max_value
|
|
33
33
|
|
|
@@ -35,7 +35,7 @@ def expo(
|
|
|
35
35
|
def decay(
|
|
36
36
|
initial_value: float = 1,
|
|
37
37
|
decay_factor: float = 1,
|
|
38
|
-
min_value: Optional[float] = None
|
|
38
|
+
min_value: Optional[float] = None,
|
|
39
39
|
) -> Generator[float, Any, None]:
|
|
40
40
|
|
|
41
41
|
"""Generator for exponential decay[1]:
|
|
@@ -83,7 +83,7 @@ def fibo(max_value: Optional[int] = None) -> Generator[int, None, None]:
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
def constant(
|
|
86
|
-
interval: Union[int, Iterable[float]] = 1
|
|
86
|
+
interval: Union[int, Iterable[float]] = 1,
|
|
87
87
|
) -> Generator[float, None, None]:
|
|
88
88
|
"""Generator for constant intervals.
|
|
89
89
|
|
|
@@ -104,7 +104,7 @@ def constant(
|
|
|
104
104
|
|
|
105
105
|
def runtime(
|
|
106
106
|
*,
|
|
107
|
-
value: Callable[[Any], float]
|
|
107
|
+
value: Callable[[Any], float],
|
|
108
108
|
) -> Generator[float, None, None]:
|
|
109
109
|
"""Generator that is based on parsing the return value or thrown
|
|
110
110
|
exception of the decorated method
|
backoff/types.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-backoff
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Function decoration for backoff and retry
|
|
5
5
|
Project-URL: Documentation, https://python-backoff.github.io/backoff
|
|
6
6
|
Project-URL: Repository, https://github.com/python-backoff/backoff
|
|
@@ -16,7 +16,6 @@ Classifier: Natural Language :: English
|
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.8
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.9
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -28,7 +27,7 @@ Classifier: Programming Language :: Python :: 3.15
|
|
|
28
27
|
Classifier: Topic :: Internet :: WWW/HTTP
|
|
29
28
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
30
29
|
Classifier: Topic :: Utilities
|
|
31
|
-
Requires-Python: >=3.
|
|
30
|
+
Requires-Python: >=3.8
|
|
32
31
|
Description-Content-Type: text/x-rst
|
|
33
32
|
|
|
34
33
|
backoff
|
|
@@ -38,8 +37,8 @@ backoff
|
|
|
38
37
|
:target: https://github.com/python-backoff/backoff/actions/workflows/ci.yaml
|
|
39
38
|
.. image:: https://github.com/python-backoff/backoff/workflows/CodeQL/badge.svg
|
|
40
39
|
:target: https://github.com/python-backoff/backoff/actions/workflows/codeql-analysis.yml
|
|
41
|
-
.. image:: https://img.shields.io/pypi/v/backoff.svg
|
|
42
|
-
:target: https://pypi.python.org/pypi/backoff
|
|
40
|
+
.. image:: https://img.shields.io/pypi/v/python-backoff.svg
|
|
41
|
+
:target: https://pypi.python.org/pypi/python-backoff
|
|
43
42
|
.. image:: https://img.shields.io/github/license/python-backoff/backoff
|
|
44
43
|
:target: https://github.com/python-backoff/backoff/blob/main/LICENSE
|
|
45
44
|
|
|
@@ -201,7 +200,7 @@ gets a non-falsey result could be defined like like this:
|
|
|
201
200
|
def poll_for_message(queue):
|
|
202
201
|
return queue.get()
|
|
203
202
|
|
|
204
|
-
The jitter is disabled in order to keep the polling frequency fixed.
|
|
203
|
+
The jitter is disabled in order to keep the polling frequency fixed.
|
|
205
204
|
|
|
206
205
|
@backoff.runtime
|
|
207
206
|
----------------
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
backoff/__init__.py,sha256=cxmsrw6PUsF2VsUnaX-gyKsJ5If3iKVIKoVU5Fg2njc,928
|
|
2
|
+
backoff/_async.py,sha256=e09CDHH3x16oCS5SEi8RRK9DIyBqGT5pK1JE80awIqk,6675
|
|
3
|
+
backoff/_common.py,sha256=cz5AKeSyFxjZ5-g9YK_MB_u1yRt3N3x81EbMZGz7inI,3480
|
|
4
|
+
backoff/_decorator.py,sha256=EKqIQ6Igv2sNGAYhZlqsWGHyvu90AE9HQvTj8joXJA8,9820
|
|
5
|
+
backoff/_jitter.py,sha256=LjJShpjryk9sWBCWiz-3UX1DJCx6rebNJ5Bf3nPMlYQ,782
|
|
6
|
+
backoff/_sync.py,sha256=2Klcl79pg7AeX6h6j0Pnt-Cfx0w3CftgiMSPRPq6TL4,4089
|
|
7
|
+
backoff/_typing.py,sha256=K4xjbkoQUuKt5E1cEAUgIPrhrV2lWD3BXmgu8_Mv7rQ,1422
|
|
8
|
+
backoff/_wait_gen.py,sha256=aPTQQHmi9k_XpOUsuSoGyW-EpEOwUErLfG_IbNXmaY0,3262
|
|
9
|
+
backoff/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
backoff/types.py,sha256=fPaXJ_J81Bme-F2-RKeVDjB3Rvfnj9K4tumDDS03bNs,74
|
|
11
|
+
python_backoff-2.3.0.dist-info/METADATA,sha256=RjKF4ttvWjzuy-7IPMhbevvS92tpeyu-woDJs3IOMMs,14910
|
|
12
|
+
python_backoff-2.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
13
|
+
python_backoff-2.3.0.dist-info/licenses/LICENSE,sha256=KmtNX4hNTXob8E6n3xlEzxKzLjWnmobQoHWi0_QPuaw,1077
|
|
14
|
+
python_backoff-2.3.0.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
backoff/__init__.py,sha256=cxmsrw6PUsF2VsUnaX-gyKsJ5If3iKVIKoVU5Fg2njc,928
|
|
2
|
-
backoff/_async.py,sha256=gX-MFZWs1-6dyUsohHtJxAP_Zg0if5n8MSmHyNFTB5I,6790
|
|
3
|
-
backoff/_common.py,sha256=8s3_5AJH8hiHd9GR2PdKqiaeE2sdEUoyf6cW9OCo1F8,3478
|
|
4
|
-
backoff/_decorator.py,sha256=Vx9IlrmA22tjNgo-YN4FHqcC0W54wL-4Ug4dTdjUHZ8,9815
|
|
5
|
-
backoff/_jitter.py,sha256=LjJShpjryk9sWBCWiz-3UX1DJCx6rebNJ5Bf3nPMlYQ,782
|
|
6
|
-
backoff/_sync.py,sha256=DT_ktufPPb0nut9WCAKe5UE7sTYRl9f93PRPX6jP8ro,4214
|
|
7
|
-
backoff/_typing.py,sha256=K4xjbkoQUuKt5E1cEAUgIPrhrV2lWD3BXmgu8_Mv7rQ,1422
|
|
8
|
-
backoff/_wait_gen.py,sha256=hObFPeXDXdzcvMhkknya3nlSKYoCAMT5LFoto25emuI,3241
|
|
9
|
-
backoff/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
backoff/types.py,sha256=4DGG6Ltcz0wVfXrk0YBOnp_oPpcki4c0BOnodRhgoqg,73
|
|
11
|
-
python_backoff-2.2.2rc1.dist-info/METADATA,sha256=NxbuUUJetGK9vIbuDh1dLf3N-yD08J8fxxvtpwOEkRk,14951
|
|
12
|
-
python_backoff-2.2.2rc1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
13
|
-
python_backoff-2.2.2rc1.dist-info/licenses/LICENSE,sha256=KmtNX4hNTXob8E6n3xlEzxKzLjWnmobQoHWi0_QPuaw,1077
|
|
14
|
-
python_backoff-2.2.2rc1.dist-info/RECORD,,
|
|
File without changes
|