aiomisc 17.5.15__py3-none-any.whl → 17.5.19__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/aggregate.py CHANGED
@@ -7,8 +7,8 @@ from dataclasses import dataclass
7
7
  from inspect import Parameter
8
8
  from typing import (
9
9
  Any,
10
- Awaitable,
11
10
  Callable,
11
+ Coroutine,
12
12
  Generic,
13
13
  Iterable,
14
14
  List,
@@ -246,7 +246,7 @@ class Aggregator(AggregatorAsync[V, R], Generic[V, R]):
246
246
 
247
247
  def aggregate(
248
248
  leeway_ms: float, max_count: Optional[int] = None
249
- ) -> Callable[[AggregateFunc[V, R]], Callable[[V], Awaitable[R]]]:
249
+ ) -> Callable[[AggregateFunc[V, R]], Callable[[V], Coroutine[Any, Any, R]]]:
250
250
  """
251
251
  Parametric decorator that aggregates multiple
252
252
  (but no more than ``max_count`` defaulting to ``None``) single-argument
@@ -275,7 +275,9 @@ def aggregate(
275
275
 
276
276
  :return:
277
277
  """
278
- def decorator(func: AggregateFunc[V, R]) -> Callable[[V], Awaitable[R]]:
278
+ def decorator(
279
+ func: AggregateFunc[V, R]
280
+ ) -> Callable[[V], Coroutine[Any, Any, R]]:
279
281
  aggregator = Aggregator(
280
282
  func, max_count=max_count, leeway_ms=leeway_ms,
281
283
  )
@@ -285,7 +287,10 @@ def aggregate(
285
287
 
286
288
  def aggregate_async(
287
289
  leeway_ms: float, max_count: Optional[int] = None,
288
- ) -> Callable[[AggregateAsyncFunc[V, R]], Callable[[V], Awaitable[R]]]:
290
+ ) -> Callable[
291
+ [AggregateAsyncFunc[V, R]],
292
+ Callable[[V], Coroutine[Any, Any, R]]
293
+ ]:
289
294
  """
290
295
  Same as ``aggregate``, but with ``func`` arguments of type ``Arg``
291
296
  containing ``value`` and ``future`` attributes instead. In this setting
@@ -298,7 +303,7 @@ def aggregate_async(
298
303
  """
299
304
  def decorator(
300
305
  func: AggregateAsyncFunc[V, R]
301
- ) -> Callable[[V], Awaitable[R]]:
306
+ ) -> Callable[[V], Coroutine[Any, Any, R]]:
302
307
  aggregator = AggregatorAsync(
303
308
  func, max_count=max_count, leeway_ms=leeway_ms,
304
309
  )
aiomisc/backoff.py CHANGED
@@ -2,7 +2,7 @@ import asyncio
2
2
  import sys
3
3
  from functools import wraps
4
4
  from typing import (
5
- Any, Awaitable, Callable, Optional, Tuple, Type, TypeVar, Union,
5
+ Any, Callable, Coroutine, Optional, Tuple, Type, TypeVar, Union,
6
6
  )
7
7
 
8
8
  from .counters import Statistic
@@ -42,7 +42,10 @@ def asyncbackoff(
42
42
  giveup: Optional[Callable[[Exception], bool]] = None,
43
43
  statistic_name: Optional[str] = None,
44
44
  statistic_class: Type[BackoffStatistic] = BackoffStatistic,
45
- ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
45
+ ) -> Callable[
46
+ [Callable[P, Coroutine[Any, Any, T]]],
47
+ Callable[P, Coroutine[Any, Any, T]],
48
+ ]:
46
49
  """
47
50
  Patametric decorator that ensures that ``attempt_timeout`` and
48
51
  ``deadline`` time limits are met by decorated function.
@@ -85,7 +88,9 @@ def asyncbackoff(
85
88
  exceptions = tuple(exceptions) or ()
86
89
  exceptions += asyncio.TimeoutError,
87
90
 
88
- def decorator(func: Callable[P, Awaitable[T]]) -> Callable[P, Awaitable[T]]:
91
+ def decorator(
92
+ func: Callable[P, Coroutine[Any, Any, T]]
93
+ ) -> Callable[P, Coroutine[Any, Any, T]]:
89
94
  if attempt_timeout is not None:
90
95
  func = timeout(attempt_timeout)(func)
91
96
 
@@ -145,7 +150,10 @@ def asyncretry(
145
150
  pause: Number = 0,
146
151
  giveup: Optional[Callable[[Exception], bool]] = None,
147
152
  statistic_name: Optional[str] = None,
148
- ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
153
+ ) -> Callable[
154
+ [Callable[P, Coroutine[Any, Any, T]]],
155
+ Callable[P, Coroutine[Any, Any, T]],
156
+ ]:
149
157
  """
150
158
  Shortcut of ``asyncbackoff(None, None, 0, Exception)``.
151
159
 
@@ -24,6 +24,7 @@ UvicornApplication = Union[ASGIApplication, Callable]
24
24
  class UvicornService(Service, abc.ABC):
25
25
  __async_required__: Tuple[str, ...] = (
26
26
  "start",
27
+ "stop",
27
28
  "create_application",
28
29
  )
29
30
 
@@ -114,8 +115,11 @@ class UvicornService(Service, abc.ABC):
114
115
  )
115
116
  if not self.sock:
116
117
  self.sock = config.bind_socket()
117
- server = Server(config)
118
-
119
- self.start_event.set()
118
+ self.server = Server(config)
119
+ self.serve_task = asyncio.create_task(
120
+ self.server.serve(sockets=[self.sock])
121
+ )
120
122
 
121
- await server.serve(sockets=[self.sock])
123
+ async def stop(self, exception: Optional[Exception] = None) -> None:
124
+ self.server.should_exit = True
125
+ await self.serve_task
aiomisc/timeout.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import asyncio
2
2
  import sys
3
3
  from functools import wraps
4
- from typing import Awaitable, Callable, TypeVar, Union
4
+ from typing import Any, Callable, Coroutine, TypeVar, Union
5
5
 
6
6
 
7
7
  if sys.version_info >= (3, 10):
@@ -17,10 +17,13 @@ Number = Union[int, float]
17
17
 
18
18
  def timeout(
19
19
  value: Number
20
- ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
20
+ ) -> Callable[
21
+ [Callable[P, Coroutine[Any, Any, T]]],
22
+ Callable[P, Coroutine[Any, Any, T]],
23
+ ]:
21
24
  def decorator(
22
- func: Callable[P, Awaitable[T]],
23
- ) -> Callable[P, Awaitable[T]]:
25
+ func: Callable[P, Coroutine[Any, Any, T]],
26
+ ) -> Callable[P, Coroutine[Any, Any, T]]:
24
27
  if not asyncio.iscoroutinefunction(func):
25
28
  raise TypeError("Function is not a coroutine function")
26
29
 
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, 15)
6
- __version__ = "17.5.15"
5
+ version_info = (17, 5, 19)
6
+ __version__ = "17.5.19"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiomisc
3
- Version: 17.5.15
3
+ Version: 17.5.19
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
- aiomisc/aggregate.py,sha256=HU_kVLzA-BdySOH3UIfTEuB2Ty1uUC200hZf4upI504,8834
4
- aiomisc/backoff.py,sha256=BgdT_MEByFJPyEHjfghC7WhnEen2Lpf4p2VLZV_KVi0,5605
3
+ aiomisc/aggregate.py,sha256=4yAsJhtRc-ikm9hXer05DgYhJFGf94IXeWJRTCSSDpw,8898
4
+ aiomisc/backoff.py,sha256=v8G4A-z9o6ou4oa-hSv3UtLPX2Km8PLsEGqHHAFtu24,5701
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
@@ -34,12 +34,12 @@ aiomisc/service/tcp.py,sha256=gIdm4wXT191TMpL3Yzm_I7y--1kVxBLioN5lBP8mlhs,5507
34
34
  aiomisc/service/tls.py,sha256=oFTYVe2zf1Ow_Gniem9WyNj_SkD3q95bcsz8LWAYqdI,7325
35
35
  aiomisc/service/tracer.py,sha256=_dxk5y2JEteki9J1OXnOkI-EowD9vakSfsLaRDB4uMQ,2826
36
36
  aiomisc/service/udp.py,sha256=_uHzMAkpd7y-yt3tE9jN2llEETG7r47g2DF1SO7xyig,3616
37
- aiomisc/service/uvicorn.py,sha256=mzx3nltiWEDFm9u680UdejR51Z-2Q_S8s-tizK9gamE,4132
37
+ aiomisc/service/uvicorn.py,sha256=dR-d5ge3KsCIEJfJ6SiFQ7rIyX8rKWNuGV2ZrONToj4,4323
38
38
  aiomisc/signal.py,sha256=_iiC2jukXg7-LLirIl1YATlKIIsKLbmTNFr1Ezheu7g,1728
39
39
  aiomisc/thread_pool.py,sha256=Wx0LskSv1dGWoen1lEFRacjVco62hHn6oDaM_XKH6uo,14035
40
- aiomisc/timeout.py,sha256=rTipPBz0GOqDZG2euVxU_6PjI63nFD_bDsy_DOHHBDQ,863
40
+ aiomisc/timeout.py,sha256=OhXCvQGbPZA9IQ7cRT7ZlZnsbmDgH5ioErQyjeqIEzY,919
41
41
  aiomisc/utils.py,sha256=6yTfTpeRCVzfZp-MJCmB1oayOHUBVwQwzC3U5PBAjn8,11919
42
- aiomisc/version.py,sha256=3CjPNeI8EmqIvEF59PTZGYfu6jqFp-DP1QFO8gJ6w_s,156
42
+ aiomisc/version.py,sha256=odBh1eKbwuyH3UbIQvMW8HS8tbOp_JipLKeZLhkGEcI,156
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.15.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
61
- aiomisc-17.5.15.dist-info/METADATA,sha256=74u26dLlBO_yNtGagNvQTMN-ZT2KNMl-rUhV0aUJIfY,15664
62
- aiomisc-17.5.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
63
- aiomisc-17.5.15.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
64
- aiomisc-17.5.15.dist-info/RECORD,,
60
+ aiomisc-17.5.19.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
61
+ aiomisc-17.5.19.dist-info/METADATA,sha256=qYOCMg8EgsBD0YbYrPk5skdYAm0VkprorohY90LWXPo,15664
62
+ aiomisc-17.5.19.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
63
+ aiomisc-17.5.19.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
64
+ aiomisc-17.5.19.dist-info/RECORD,,