python-backoff 2.3.0__py3-none-any.whl → 2.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-backoff
3
- Version: 2.3.0
3
+ Version: 2.4.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
@@ -11,12 +11,10 @@ License-File: LICENSE
11
11
  Keywords: backoff,decorators,retry
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
14
  Classifier: Natural Language :: English
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Programming Language :: Python
18
17
  Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.8
20
18
  Classifier: Programming Language :: Python :: 3.9
21
19
  Classifier: Programming Language :: Python :: 3.10
22
20
  Classifier: Programming Language :: Python :: 3.11
@@ -27,7 +25,7 @@ Classifier: Programming Language :: Python :: 3.15
27
25
  Classifier: Topic :: Internet :: WWW/HTTP
28
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
27
  Classifier: Topic :: Utilities
30
- Requires-Python: >=3.8
28
+ Requires-Python: >=3.9
31
29
  Description-Content-Type: text/x-rst
32
30
 
33
31
  backoff
@@ -58,7 +56,7 @@ for asynchronous code.
58
56
  Examples
59
57
  ========
60
58
 
61
- Since Kenneth Reitz's `requests <http://python-requests.org>`_ module
59
+ Since Kenneth Reitz's `requests <https://requests.readthedocs.io>`_ module
62
60
  has become a defacto standard for synchronous HTTP clients in Python,
63
61
  networking examples below are written using it, but it is in no way required
64
62
  by the backoff module.
@@ -72,8 +70,10 @@ is raised. Here's an example using exponential backoff when any
72
70
 
73
71
  .. code-block:: python
74
72
 
75
- @backoff.on_exception(backoff.expo,
76
- requests.exceptions.RequestException)
73
+ @backoff.on_exception(
74
+ backoff.expo,
75
+ requests.exceptions.RequestException,
76
+ )
77
77
  def get_url(url):
78
78
  return requests.get(url)
79
79
 
@@ -82,9 +82,13 @@ the same backoff behavior is desired for more than one exception type:
82
82
 
83
83
  .. code-block:: python
84
84
 
85
- @backoff.on_exception(backoff.expo,
86
- (requests.exceptions.Timeout,
87
- requests.exceptions.ConnectionError))
85
+ @backoff.on_exception(
86
+ backoff.expo,
87
+ (
88
+ requests.exceptions.Timeout,
89
+ requests.exceptions.ConnectionError,
90
+ ),
91
+ )
88
92
  def get_url(url):
89
93
  return requests.get(url)
90
94
 
@@ -98,9 +102,11 @@ of total time in seconds that can elapse before giving up.
98
102
 
99
103
  .. code-block:: python
100
104
 
101
- @backoff.on_exception(backoff.expo,
102
- requests.exceptions.RequestException,
103
- max_time=60)
105
+ @backoff.on_exception(
106
+ backoff.expo,
107
+ requests.exceptions.RequestException,
108
+ max_time=60,
109
+ )
104
110
  def get_url(url):
105
111
  return requests.get(url)
106
112
 
@@ -110,10 +116,12 @@ to make to the target function before giving up.
110
116
 
111
117
  .. code-block:: python
112
118
 
113
- @backoff.on_exception(backoff.expo,
114
- requests.exceptions.RequestException,
115
- max_tries=8,
116
- jitter=None)
119
+ @backoff.on_exception(
120
+ backoff.expo,
121
+ requests.exceptions.RequestException,
122
+ max_tries=8,
123
+ jitter=None,
124
+ )
117
125
  def get_url(url):
118
126
  return requests.get(url)
119
127
 
@@ -129,10 +137,13 @@ be retried:
129
137
  def fatal_code(e):
130
138
  return 400 <= e.response.status_code < 500
131
139
 
132
- @backoff.on_exception(backoff.expo,
133
- requests.exceptions.RequestException,
134
- max_time=300,
135
- giveup=fatal_code)
140
+
141
+ @backoff.on_exception(
142
+ backoff.expo,
143
+ requests.exceptions.RequestException,
144
+ max_time=300,
145
+ giveup=fatal_code,
146
+ )
136
147
  def get_url(url):
137
148
  return requests.get(url)
138
149
 
@@ -150,11 +161,14 @@ case, regardless of the logic in the `on_exception` handler.
150
161
  def fatal_code(e):
151
162
  return 400 <= e.response.status_code < 500
152
163
 
153
- @backoff.on_exception(backoff.expo,
154
- requests.exceptions.RequestException,
155
- max_time=300,
156
- raise_on_giveup=False,
157
- giveup=fatal_code)
164
+
165
+ @backoff.on_exception(
166
+ backoff.expo,
167
+ requests.exceptions.RequestException,
168
+ max_time=300,
169
+ raise_on_giveup=False,
170
+ giveup=fatal_code,
171
+ )
158
172
  def get_url(url):
159
173
  return requests.get(url)
160
174
 
@@ -174,7 +188,11 @@ return value of the target function is the empty list:
174
188
 
175
189
  .. code-block:: python
176
190
 
177
- @backoff.on_predicate(backoff.fibo, lambda x: x == [], max_value=13)
191
+ @backoff.on_predicate(
192
+ backoff.fibo,
193
+ lambda x: x == [],
194
+ max_value=13,
195
+ )
178
196
  def poll_for_messages(queue):
179
197
  return queue.get()
180
198
 
@@ -196,7 +214,11 @@ gets a non-falsey result could be defined like like this:
196
214
 
197
215
  .. code-block:: python
198
216
 
199
- @backoff.on_predicate(backoff.constant, jitter=None, interval=1)
217
+ @backoff.on_predicate(
218
+ backoff.constant,
219
+ jitter=None,
220
+ interval=1,
221
+ )
200
222
  def poll_for_message(queue):
201
223
  return queue.get()
202
224
 
@@ -249,12 +271,16 @@ backoff behavior for different cases:
249
271
  .. code-block:: python
250
272
 
251
273
  @backoff.on_predicate(backoff.fibo, max_value=13)
252
- @backoff.on_exception(backoff.expo,
253
- requests.exceptions.HTTPError,
254
- max_time=60)
255
- @backoff.on_exception(backoff.expo,
256
- requests.exceptions.Timeout,
257
- max_time=300)
274
+ @backoff.on_exception(
275
+ backoff.expo,
276
+ requests.exceptions.HTTPError,
277
+ max_time=60,
278
+ )
279
+ @backoff.on_exception(
280
+ backoff.expo,
281
+ requests.exceptions.Timeout,
282
+ max_time=300,
283
+ )
258
284
  def poll_for_message(queue):
259
285
  return queue.get()
260
286
 
@@ -277,9 +303,13 @@ runtime to obtain the value:
277
303
  # and that it has a dictionary-like 'config' property
278
304
  return app.config["BACKOFF_MAX_TIME"]
279
305
 
280
- @backoff.on_exception(backoff.expo,
281
- ValueError,
282
- max_time=lookup_max_time)
306
+
307
+ @backoff.on_exception(
308
+ backoff.expo,
309
+ ValueError,
310
+ max_time=lookup_max_time,
311
+ )
312
+ def my_function(): ...
283
313
 
284
314
  Event handlers
285
315
  --------------
@@ -307,13 +337,18 @@ implemented like so:
307
337
  .. code-block:: python
308
338
 
309
339
  def backoff_hdlr(details):
310
- print ("Backing off {wait:0.1f} seconds after {tries} tries "
311
- "calling function {target} with args {args} and kwargs "
312
- "{kwargs}".format(**details))
340
+ print(
341
+ "Backing off {wait:0.1f} seconds after {tries} tries "
342
+ "calling function {target} with args {args} and kwargs "
343
+ "{kwargs}".format(**details)
344
+ )
345
+
313
346
 
314
- @backoff.on_exception(backoff.expo,
315
- requests.exceptions.RequestException,
316
- on_backoff=backoff_hdlr)
347
+ @backoff.on_exception(
348
+ backoff.expo,
349
+ requests.exceptions.RequestException,
350
+ on_backoff=backoff_hdlr,
351
+ )
317
352
  def get_url(url):
318
353
  return requests.get(url)
319
354
 
@@ -325,9 +360,14 @@ handler functions as the value of the ``on_backoff`` keyword arg:
325
360
 
326
361
  .. code-block:: python
327
362
 
328
- @backoff.on_exception(backoff.expo,
329
- requests.exceptions.RequestException,
330
- on_backoff=[backoff_hdlr1, backoff_hdlr2])
363
+ @backoff.on_exception(
364
+ backoff.expo,
365
+ requests.exceptions.RequestException,
366
+ on_backoff=[
367
+ backoff_hdlr1,
368
+ backoff_hdlr2,
369
+ ],
370
+ )
331
371
  def get_url(url):
332
372
  return requests.get(url)
333
373
 
@@ -358,9 +398,13 @@ asynchronous HTTP client/server library.
358
398
 
359
399
  .. code-block:: python
360
400
 
361
- @backoff.on_exception(backoff.expo, aiohttp.ClientError, max_time=60)
401
+ @backoff.on_exception(
402
+ backoff.expo,
403
+ aiohttp.ClientError,
404
+ max_time=60,
405
+ )
362
406
  async def get_url(url):
363
- async with aiohttp.ClientSession(raise_for_status=True) as session:
407
+ async with aiohttp.ClientSession(raise_for_status=True) as session: # ruff:ignore[multiple-with-statements]
364
408
  async with session.get(url) as response:
365
409
  return await response.text()
366
410
 
@@ -375,7 +419,7 @@ as:
375
419
 
376
420
  .. code-block:: python
377
421
 
378
- logging.getLogger('backoff').addHandler(logging.StreamHandler())
422
+ logging.getLogger("backoff").addHandler(logging.StreamHandler())
379
423
 
380
424
  The default logging level is INFO, which corresponds to logging
381
425
  anytime a retry event occurs. If you would instead like to log
@@ -383,7 +427,7 @@ only when a giveup event occurs, set the logger level to ERROR.
383
427
 
384
428
  .. code-block:: python
385
429
 
386
- logging.getLogger('backoff').setLevel(logging.ERROR)
430
+ logging.getLogger("backoff").setLevel(logging.ERROR)
387
431
 
388
432
  It is also possible to specify an alternate logger with the ``logger``
389
433
  keyword argument. If a string value is specified the logger will be
@@ -391,25 +435,30 @@ looked up by name.
391
435
 
392
436
  .. code-block:: python
393
437
 
394
- @backoff.on_exception(backoff.expo,
395
- requests.exceptions.RequestException,
396
- logger='my_logger')
397
- # ...
438
+ @backoff.on_exception(
439
+ backoff.expo,
440
+ requests.exceptions.RequestException,
441
+ logger="my_logger",
442
+ )
443
+ def my_function(): ...
398
444
 
399
445
  It is also supported to specify a Logger (or LoggerAdapter) object
400
446
  directly.
401
447
 
402
448
  .. code-block:: python
403
449
 
404
- my_logger = logging.getLogger('my_logger')
450
+ my_logger = logging.getLogger("my_logger")
405
451
  my_handler = logging.StreamHandler()
406
452
  my_logger.addHandler(my_handler)
407
453
  my_logger.setLevel(logging.ERROR)
408
454
 
409
- @backoff.on_exception(backoff.expo,
410
- requests.exceptions.RequestException,
411
- logger=my_logger)
412
- # ...
455
+
456
+ @backoff.on_exception(
457
+ backoff.expo,
458
+ requests.exceptions.RequestException,
459
+ logger=my_logger,
460
+ )
461
+ def my_function(): ...
413
462
 
414
463
  Default logging can be disabled all together by specifying
415
464
  ``logger=None``. In this case, if desired alternative logging behavior
@@ -0,0 +1,14 @@
1
+ backoff/__init__.py,sha256=BeZF5I4RDsBoy2C1xNvabGaJ5ez6m8JFteZYElAL_RM,988
2
+ backoff/_async.py,sha256=xx5z-gkSK484W09d2On9vTQvnMbK-KyzVuiZPR67zFA,8936
3
+ backoff/_common.py,sha256=2p0oj1toXysJ7jVxYr6fZ3Q3Pa7CYpje44k116C7il4,8939
4
+ backoff/_decorator.py,sha256=rMTzMgRz7tPI0sIy6tCI9Q0RBStRX7bcgYuiYg9TlKU,16114
5
+ backoff/_jitter.py,sha256=wzQHBDNuYg7owbc3fcZLOr5uhhRgqiuncU5rIYOB9lY,766
6
+ backoff/_sync.py,sha256=iL5JBScW-l93opMSs09lSHMBFnrDBWjpml_Ar12yJME,6510
7
+ backoff/_typing.py,sha256=RkIqYIJwjUlhwg5Z6TIF3HkCIv1oKDAtDGRDZJO0K48,1856
8
+ backoff/_wait_gen.py,sha256=uyDnfEcOzUpLeGqktkVZ2pBr-NKu4K03qYug-VR_KJo,3056
9
+ backoff/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ backoff/types.py,sha256=rOQAfuetqVwfEIuzVvK5D_w97A3wrZ9lQ8HwuJ_uq5s,59
11
+ python_backoff-2.4.0.dist-info/METADATA,sha256=Xek_me-7Sxh1vUE8Tb5NSdeSylTrBIUruOUJwLsQ7XQ,14809
12
+ python_backoff-2.4.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
13
+ python_backoff-2.4.0.dist-info/licenses/LICENSE,sha256=KmtNX4hNTXob8E6n3xlEzxKzLjWnmobQoHWi0_QPuaw,1077
14
+ python_backoff-2.4.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.28.0
2
+ Generator: hatchling 1.31.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,14 +0,0 @@
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,,