aiomisc 17.5.6__py3-none-any.whl → 17.5.8__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.
aiomisc/backoff.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import sys
2
3
  from functools import wraps
3
4
  from typing import (
4
5
  Any, Awaitable, Callable, Optional, Tuple, Type, TypeVar, Union,
@@ -8,12 +9,15 @@ from .counters import Statistic
8
9
  from .timeout import timeout
9
10
 
10
11
 
11
- Number = Union[int, float]
12
- T = TypeVar("T")
12
+ if sys.version_info >= (3, 10):
13
+ from typing import ParamSpec
14
+ else:
15
+ from typing_extensions import ParamSpec
13
16
 
14
17
 
15
- WrapReturnType = Callable[..., Awaitable[T]]
16
- ReturnType = Callable[..., WrapReturnType]
18
+ Number = Union[int, float]
19
+ T = TypeVar("T")
20
+ P = ParamSpec("P")
17
21
 
18
22
 
19
23
  class BackoffStatistic(Statistic):
@@ -38,7 +42,7 @@ def asyncbackoff(
38
42
  giveup: Optional[Callable[[Exception], bool]] = None,
39
43
  statistic_name: Optional[str] = None,
40
44
  statistic_class: Type[BackoffStatistic] = BackoffStatistic,
41
- ) -> ReturnType:
45
+ ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
42
46
  """
43
47
  Patametric decorator that ensures that ``attempt_timeout`` and
44
48
  ``deadline`` time limits are met by decorated function.
@@ -81,12 +85,12 @@ def asyncbackoff(
81
85
  exceptions = tuple(exceptions) or ()
82
86
  exceptions += asyncio.TimeoutError,
83
87
 
84
- def decorator(func: WrapReturnType) -> WrapReturnType:
88
+ def decorator(func: Callable[P, Awaitable[T]]) -> Callable[P, Awaitable[T]]:
85
89
  if attempt_timeout is not None:
86
90
  func = timeout(attempt_timeout)(func)
87
91
 
88
92
  @wraps(func)
89
- async def wrap(*args: Any, **kwargs: Any) -> T:
93
+ async def wrap(*args: P.args, **kwargs: P.kwargs) -> T:
90
94
  last_exc = None
91
95
  tries = 0
92
96
 
@@ -141,7 +145,7 @@ def asyncretry(
141
145
  pause: Number = 0,
142
146
  giveup: Optional[Callable[[Exception], bool]] = None,
143
147
  statistic_name: Optional[str] = None,
144
- ) -> ReturnType:
148
+ ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
145
149
  """
146
150
  Shortcut of ``asyncbackoff(None, None, 0, Exception)``.
147
151
 
aiomisc/timeout.py CHANGED
@@ -1,22 +1,31 @@
1
1
  import asyncio
2
+ import sys
2
3
  from functools import wraps
3
- from typing import Any, Awaitable, Callable, TypeVar, Union
4
+ from typing import Awaitable, Callable, TypeVar, Union
5
+
6
+
7
+ if sys.version_info >= (3, 10):
8
+ from typing import ParamSpec
9
+ else:
10
+ from typing_extensions import ParamSpec
4
11
 
5
12
 
6
13
  T = TypeVar("T")
14
+ P = ParamSpec("P")
7
15
  Number = Union[int, float]
8
- FuncType = Callable[..., Awaitable[T]]
9
16
 
10
17
 
11
- def timeout(value: Number) -> Callable[[FuncType], FuncType]:
18
+ def timeout(
19
+ value: Number
20
+ ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
12
21
  def decorator(
13
- func: FuncType,
14
- ) -> FuncType:
22
+ func: Callable[P, Awaitable[T]],
23
+ ) -> Callable[P, Awaitable[T]]:
15
24
  if not asyncio.iscoroutinefunction(func):
16
25
  raise TypeError("Function is not a coroutine function")
17
26
 
18
27
  @wraps(func)
19
- async def wrap(*args: Any, **kwargs: Any) -> T:
28
+ async def wrap(*args: P.args, **kwargs: P.kwargs) -> T:
20
29
  return await asyncio.wait_for(
21
30
  func(*args, **kwargs),
22
31
  timeout=value,
aiomisc/version.py CHANGED
@@ -2,5 +2,5 @@
2
2
  # BY: poem-plugins "git" plugin
3
3
  # NEVER EDIT THIS FILE MANUALLY
4
4
 
5
- version_info = (17, 5, 6)
6
- __version__ = "17.5.6"
5
+ version_info = (17, 5, 8)
6
+ __version__ = "17.5.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiomisc
3
- Version: 17.5.6
3
+ Version: 17.5.8
4
4
  Summary: aiomisc - miscellaneous utils for asyncio
5
5
  Home-page: https://github.com/aiokitchen/aiomisc
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  aiomisc/__init__.py,sha256=mgLaoGB3-WTAnrUfEN9nM_0Z_XU6xojkx1ISmW204UA,2253
2
2
  aiomisc/_context_vars.py,sha256=28A7j_NABitKMtpxuFvxQ2wCr-Fq79dAC3YjqVLLeTQ,689
3
3
  aiomisc/aggregate.py,sha256=srcL3_hwD3noLYo65wx3mI0mTjDyv9B5DsO_3C1XLfs,7819
4
- aiomisc/backoff.py,sha256=o1D-w7CvNvehSZZtUSe8pGp_eGFX6zRZyc_RRL91iwI,5410
4
+ aiomisc/backoff.py,sha256=BgdT_MEByFJPyEHjfghC7WhnEen2Lpf4p2VLZV_KVi0,5605
5
5
  aiomisc/circuit_breaker.py,sha256=nZVLuGg4rKxn84CHaIvRfBYumgdwx2VZloF8OprQKuk,12581
6
6
  aiomisc/compat.py,sha256=aYVe0J-2CvAzUHPAULNhrfMLFYNKN-z3Sg7nlBkzfxw,3291
7
7
  aiomisc/context.py,sha256=j2YRNGDAJbrg94OkFyIMyYKHKzHRRL8tSAWma1yxNKE,1549
@@ -37,9 +37,9 @@ aiomisc/service/udp.py,sha256=_uHzMAkpd7y-yt3tE9jN2llEETG7r47g2DF1SO7xyig,3616
37
37
  aiomisc/service/uvicorn.py,sha256=mzx3nltiWEDFm9u680UdejR51Z-2Q_S8s-tizK9gamE,4132
38
38
  aiomisc/signal.py,sha256=_iiC2jukXg7-LLirIl1YATlKIIsKLbmTNFr1Ezheu7g,1728
39
39
  aiomisc/thread_pool.py,sha256=Wx0LskSv1dGWoen1lEFRacjVco62hHn6oDaM_XKH6uo,14035
40
- aiomisc/timeout.py,sha256=B4gDv6eXs5XHicjRifRc-Z1L7OBACyh-_QA1iAdv4g4,678
40
+ aiomisc/timeout.py,sha256=rTipPBz0GOqDZG2euVxU_6PjI63nFD_bDsy_DOHHBDQ,863
41
41
  aiomisc/utils.py,sha256=6yTfTpeRCVzfZp-MJCmB1oayOHUBVwQwzC3U5PBAjn8,11919
42
- aiomisc/version.py,sha256=ItlzgbdRpmp8PYVdHVOkS614vT0D5hvSXx8heJOKoXY,154
42
+ aiomisc/version.py,sha256=PQU3JRkX_U5Imwq4EQyXqVGBQRiKfmOGspT0GZSuCDo,154
43
43
  aiomisc/worker_pool.py,sha256=GA91KdOrBlqHthbVSTxu_d6BsBIbl-uKqW2NxqSafG0,11107
44
44
  aiomisc_log/__init__.py,sha256=ZD-Q-YTWoZdxJpMqMNMIraA_gaN0QawgnVpXz6mxd2o,4855
45
45
  aiomisc_log/enum.py,sha256=_zfCZPYCGyI9KL6TqHiYVlOfA5U5MCbsuCuDKxDHdxg,1549
@@ -57,8 +57,8 @@ aiomisc_worker/process_inner.py,sha256=8ZtjCSLrgySW57OIbuGrpEWxfysRLYKx1or1YaAqx
57
57
  aiomisc_worker/protocol.py,sha256=1smmlBbdreSmnrxuhHaUMUC10FO9xMIEcedhweQJX_A,2705
58
58
  aiomisc_worker/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  aiomisc_worker/worker.py,sha256=f8nCFhlKh84UUBUaEgCllwMRvVZiD8_UUXaeit6g3T8,3236
60
- aiomisc-17.5.6.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
61
- aiomisc-17.5.6.dist-info/METADATA,sha256=DDSm1i-bsKY8RPrNMROE_dOwHj3Tg6Pup0TpUuCrli0,15663
62
- aiomisc-17.5.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
63
- aiomisc-17.5.6.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
64
- aiomisc-17.5.6.dist-info/RECORD,,
60
+ aiomisc-17.5.8.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
61
+ aiomisc-17.5.8.dist-info/METADATA,sha256=lQU9pHmOnrbFvghqqEyJlPJMG81TA6jXpCBo6zVuwAY,15663
62
+ aiomisc-17.5.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
63
+ aiomisc-17.5.8.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
64
+ aiomisc-17.5.8.dist-info/RECORD,,