tenacity 8.4.1__py3-none-any.whl → 8.4.2__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.
tenacity/__init__.py CHANGED
@@ -329,13 +329,19 @@ class BaseRetrying(ABC):
329
329
  f, functools.WRAPPER_ASSIGNMENTS + ("__defaults__", "__kwdefaults__")
330
330
  )
331
331
  def wrapped_f(*args: t.Any, **kw: t.Any) -> t.Any:
332
- return self(f, *args, **kw)
332
+ # Always create a copy to prevent overwriting the local contexts when
333
+ # calling the same wrapped functions multiple times in the same stack
334
+ copy = self.copy()
335
+ wrapped_f.statistics = copy.statistics # type: ignore[attr-defined]
336
+ return copy(f, *args, **kw)
333
337
 
334
338
  def retry_with(*args: t.Any, **kwargs: t.Any) -> WrappedFn:
335
339
  return self.copy(*args, **kwargs).wraps(f)
336
340
 
337
- wrapped_f.retry = self # type: ignore[attr-defined]
341
+ # Preserve attributes
342
+ wrapped_f.retry = wrapped_f # type: ignore[attr-defined]
338
343
  wrapped_f.retry_with = retry_with # type: ignore[attr-defined]
344
+ wrapped_f.statistics = {} # type: ignore[attr-defined]
339
345
 
340
346
  return wrapped_f # type: ignore[return-value]
341
347
 
@@ -175,18 +175,23 @@ class AsyncRetrying(BaseRetrying):
175
175
  raise StopAsyncIteration
176
176
 
177
177
  def wraps(self, fn: WrappedFn) -> WrappedFn:
178
- fn = super().wraps(fn)
178
+ wrapped = super().wraps(fn)
179
179
  # Ensure wrapper is recognized as a coroutine function.
180
180
 
181
181
  @functools.wraps(
182
182
  fn, functools.WRAPPER_ASSIGNMENTS + ("__defaults__", "__kwdefaults__")
183
183
  )
184
184
  async def async_wrapped(*args: t.Any, **kwargs: t.Any) -> t.Any:
185
- return await fn(*args, **kwargs)
185
+ # Always create a copy to prevent overwriting the local contexts when
186
+ # calling the same wrapped functions multiple times in the same stack
187
+ copy = self.copy()
188
+ async_wrapped.statistics = copy.statistics # type: ignore[attr-defined]
189
+ return await copy(fn, *args, **kwargs)
186
190
 
187
191
  # Preserve attributes
188
- async_wrapped.retry = fn.retry # type: ignore[attr-defined]
189
- async_wrapped.retry_with = fn.retry_with # type: ignore[attr-defined]
192
+ async_wrapped.retry = async_wrapped # type: ignore[attr-defined]
193
+ async_wrapped.retry_with = wrapped.retry_with # type: ignore[attr-defined]
194
+ async_wrapped.statistics = {} # type: ignore[attr-defined]
190
195
 
191
196
  return async_wrapped # type: ignore[return-value]
192
197
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tenacity
3
- Version: 8.4.1
3
+ Version: 8.4.2
4
4
  Summary: Retry code until it succeeds
5
5
  Home-page: https://github.com/jd/tenacity
6
6
  Author: Julien Danjou
@@ -1,4 +1,4 @@
1
- tenacity/__init__.py,sha256=dT216tDrncc6QKV6_1AfuhzmCMfUzM_hIwW34ivIRsQ,23651
1
+ tenacity/__init__.py,sha256=_KlyQOzUwzhJeW9qH-_hoyFzV-AZ_aRg2f5qei8o_0I,24026
2
2
  tenacity/_utils.py,sha256=5AwPoFrGOIfPkCtqeJdFBi7KKQNcJXJ3erbtGOXtn6w,2916
3
3
  tenacity/after.py,sha256=NR4rGyslG7xF1hDJZb2Wf8wVApafX0HZwz2nFVLvaqE,1658
4
4
  tenacity/before.py,sha256=7zDTpZ3b6rkY9sOdS-qbpjBgSjVr3xBqcIqdYAh9ZKM,1544
@@ -9,10 +9,10 @@ tenacity/retry.py,sha256=PVnZfXBeLN2DzsytKexw23SPLn82AdZfFPC2OhVQ_1Y,8986
9
9
  tenacity/stop.py,sha256=wQuwGfCLw8OH1C3x0G9lH9xtJCyhgviePQ40HRAUg54,4113
10
10
  tenacity/tornadoweb.py,sha256=vS1ONfPYoGzPx1asQaVbfoo6D9tPIzSysJipm61Yqw8,2125
11
11
  tenacity/wait.py,sha256=Q9XoZCtFra53aQOyfABpvRDuUeB-NpUUXImHsUiRQI0,8042
12
- tenacity/asyncio/__init__.py,sha256=i0GgKtsRWgKH2V1ESNsv9MY5rYvbN8ViRs3oe-UNWm8,7413
12
+ tenacity/asyncio/__init__.py,sha256=SWnrZkyPTvQHvhTAcPVTLCT3LVxg5ICzhUcyt5tMxsE,7782
13
13
  tenacity/asyncio/retry.py,sha256=ymu8F1JfAerc5vDO0V4-2kCvHXqyce2jpO1Nlt6aKxI,4244
14
- tenacity-8.4.1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
15
- tenacity-8.4.1.dist-info/METADATA,sha256=mnX4jjfjt2yP61kwEC9cJVvuUUdB5COSlqE4HCge5Tg,1155
16
- tenacity-8.4.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
17
- tenacity-8.4.1.dist-info/top_level.txt,sha256=Zf8AOZMN7hr1EEcUo9U5KzXsM4TOC1pBZ22D8913JYs,9
18
- tenacity-8.4.1.dist-info/RECORD,,
14
+ tenacity-8.4.2.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
15
+ tenacity-8.4.2.dist-info/METADATA,sha256=lEJwjb1dtrlcvg7A-aGxccyqNws7q-sROWoF_1U_O44,1155
16
+ tenacity-8.4.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
17
+ tenacity-8.4.2.dist-info/top_level.txt,sha256=Zf8AOZMN7hr1EEcUo9U5KzXsM4TOC1pBZ22D8913JYs,9
18
+ tenacity-8.4.2.dist-info/RECORD,,