aiomisc 17.5.6__tar.gz → 17.5.10__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.
Files changed (64) hide show
  1. {aiomisc-17.5.6 → aiomisc-17.5.10}/PKG-INFO +1 -1
  2. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/backoff.py +12 -8
  3. aiomisc-17.5.10/aiomisc/timeout.py +34 -0
  4. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/version.py +2 -2
  5. {aiomisc-17.5.6 → aiomisc-17.5.10}/pyproject.toml +1 -1
  6. aiomisc-17.5.6/aiomisc/timeout.py +0 -25
  7. {aiomisc-17.5.6 → aiomisc-17.5.10}/COPYING +0 -0
  8. {aiomisc-17.5.6 → aiomisc-17.5.10}/README.rst +0 -0
  9. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/__init__.py +0 -0
  10. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/_context_vars.py +0 -0
  11. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/aggregate.py +0 -0
  12. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/circuit_breaker.py +0 -0
  13. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/compat.py +0 -0
  14. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/context.py +0 -0
  15. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/counters.py +0 -0
  16. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/cron.py +0 -0
  17. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/entrypoint.py +0 -0
  18. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/io.py +0 -0
  19. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/iterator_wrapper.py +0 -0
  20. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/log.py +0 -0
  21. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/periodic.py +0 -0
  22. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/plugins/__init__.py +0 -0
  23. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/plugins/__main__.py +0 -0
  24. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/pool.py +0 -0
  25. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/process_pool.py +0 -0
  26. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/py.typed +0 -0
  27. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/recurring.py +0 -0
  28. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/__init__.py +0 -0
  29. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/aiohttp.py +0 -0
  30. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/asgi.py +0 -0
  31. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/base.py +0 -0
  32. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/carbon.py +0 -0
  33. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/cron.py +0 -0
  34. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/grpc_server.py +0 -0
  35. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/periodic.py +0 -0
  36. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/process.py +0 -0
  37. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/profiler.py +0 -0
  38. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/raven.py +0 -0
  39. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/sdwatchdog.py +0 -0
  40. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/tcp.py +0 -0
  41. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/tls.py +0 -0
  42. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/tracer.py +0 -0
  43. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/udp.py +0 -0
  44. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/service/uvicorn.py +0 -0
  45. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/signal.py +0 -0
  46. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/thread_pool.py +0 -0
  47. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/utils.py +0 -0
  48. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc/worker_pool.py +0 -0
  49. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/__init__.py +0 -0
  50. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/enum.py +0 -0
  51. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/formatter/__init__.py +0 -0
  52. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/formatter/color.py +0 -0
  53. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/formatter/journald.py +0 -0
  54. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/formatter/json.py +0 -0
  55. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/formatter/rich.py +0 -0
  56. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_log/py.typed +0 -0
  57. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/__init__.py +0 -0
  58. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/__main__.py +0 -0
  59. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/forking.py +0 -0
  60. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/process.py +0 -0
  61. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/process_inner.py +0 -0
  62. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/protocol.py +0 -0
  63. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/py.typed +0 -0
  64. {aiomisc-17.5.6 → aiomisc-17.5.10}/aiomisc_worker/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiomisc
3
- Version: 17.5.6
3
+ Version: 17.5.10
4
4
  Summary: aiomisc - miscellaneous utils for asyncio
5
5
  Home-page: https://github.com/aiokitchen/aiomisc
6
6
  License: MIT
@@ -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
 
@@ -0,0 +1,34 @@
1
+ import asyncio
2
+ import sys
3
+ from functools import wraps
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
11
+
12
+
13
+ T = TypeVar("T")
14
+ P = ParamSpec("P")
15
+ Number = Union[int, float]
16
+
17
+
18
+ def timeout(
19
+ value: Number
20
+ ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
21
+ def decorator(
22
+ func: Callable[P, Awaitable[T]],
23
+ ) -> Callable[P, Awaitable[T]]:
24
+ if not asyncio.iscoroutinefunction(func):
25
+ raise TypeError("Function is not a coroutine function")
26
+
27
+ @wraps(func)
28
+ async def wrap(*args: P.args, **kwargs: P.kwargs) -> T:
29
+ return await asyncio.wait_for(
30
+ func(*args, **kwargs),
31
+ timeout=value,
32
+ )
33
+ return wrap
34
+ return decorator
@@ -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, 10)
6
+ __version__ = "17.5.10"
@@ -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.6"
4
+ version = "17.5.10"
5
5
  description = "aiomisc - miscellaneous utils for asyncio"
6
6
  authors = ["Dmitry Orlov <me@mosquito.su>"]
7
7
  readme = "README.rst"
@@ -1,25 +0,0 @@
1
- import asyncio
2
- from functools import wraps
3
- from typing import Any, Awaitable, Callable, TypeVar, Union
4
-
5
-
6
- T = TypeVar("T")
7
- Number = Union[int, float]
8
- FuncType = Callable[..., Awaitable[T]]
9
-
10
-
11
- def timeout(value: Number) -> Callable[[FuncType], FuncType]:
12
- def decorator(
13
- func: FuncType,
14
- ) -> FuncType:
15
- if not asyncio.iscoroutinefunction(func):
16
- raise TypeError("Function is not a coroutine function")
17
-
18
- @wraps(func)
19
- async def wrap(*args: Any, **kwargs: Any) -> T:
20
- return await asyncio.wait_for(
21
- func(*args, **kwargs),
22
- timeout=value,
23
- )
24
- return wrap
25
- return decorator
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