aiomisc 17.5.15__tar.gz → 17.5.19__tar.gz
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-17.5.15 → aiomisc-17.5.19}/PKG-INFO +1 -1
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/aggregate.py +10 -5
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/backoff.py +12 -4
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/uvicorn.py +8 -4
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/timeout.py +7 -4
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/version.py +2 -2
- {aiomisc-17.5.15 → aiomisc-17.5.19}/pyproject.toml +1 -1
- {aiomisc-17.5.15 → aiomisc-17.5.19}/COPYING +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/README.rst +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/__init__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/_context_vars.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/circuit_breaker.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/compat.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/context.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/counters.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/cron.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/entrypoint.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/io.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/iterator_wrapper.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/log.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/periodic.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/plugins/__init__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/plugins/__main__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/pool.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/process_pool.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/py.typed +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/recurring.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/__init__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/aiohttp.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/asgi.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/base.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/carbon.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/cron.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/grpc_server.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/periodic.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/process.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/profiler.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/raven.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/sdwatchdog.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/tcp.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/tls.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/tracer.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/service/udp.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/signal.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/thread_pool.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/utils.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc/worker_pool.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/__init__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/enum.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/formatter/__init__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/formatter/color.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/formatter/journald.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/formatter/json.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/formatter/rich.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_log/py.typed +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/__init__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/__main__.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/forking.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/process.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/process_inner.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/protocol.py +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/py.typed +0 -0
- {aiomisc-17.5.15 → aiomisc-17.5.19}/aiomisc_worker/worker.py +0 -0
@@ -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],
|
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(
|
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[
|
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],
|
306
|
+
) -> Callable[[V], Coroutine[Any, Any, R]]:
|
302
307
|
aggregator = AggregatorAsync(
|
303
308
|
func, max_count=max_count, leeway_ms=leeway_ms,
|
304
309
|
)
|
@@ -2,7 +2,7 @@ import asyncio
|
|
2
2
|
import sys
|
3
3
|
from functools import wraps
|
4
4
|
from typing import (
|
5
|
-
Any,
|
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[
|
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(
|
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[
|
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
|
-
|
118
|
+
self.server = Server(config)
|
119
|
+
self.serve_task = asyncio.create_task(
|
120
|
+
self.server.serve(sockets=[self.sock])
|
121
|
+
)
|
120
122
|
|
121
|
-
|
123
|
+
async def stop(self, exception: Optional[Exception] = None) -> None:
|
124
|
+
self.server.should_exit = True
|
125
|
+
await self.serve_task
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import asyncio
|
2
2
|
import sys
|
3
3
|
from functools import wraps
|
4
|
-
from typing import
|
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[
|
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,
|
23
|
-
) -> Callable[P,
|
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
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "aiomisc"
|
3
3
|
# This is a dummy version which will be rewritten with poem-plugins
|
4
|
-
version = "17.5.
|
4
|
+
version = "17.5.19"
|
5
5
|
description = "aiomisc - miscellaneous utils for asyncio"
|
6
6
|
authors = ["Dmitry Orlov <me@mosquito.su>"]
|
7
7
|
readme = "README.rst"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|