aiomisc 17.7.1__py3-none-any.whl → 17.7.5__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/process_pool.py CHANGED
@@ -18,9 +18,59 @@ class ProcessPoolStatistic(Statistic):
18
18
 
19
19
 
20
20
  class ProcessPoolExecutor(ProcessPoolExecutorBase, EventLoopMixin):
21
+ """
22
+ Process pool executor with statistic
23
+
24
+ Usage:
25
+
26
+ .. code-block:: python
27
+
28
+ from time import sleep
29
+ from aiomisc import ProcessPoolExecutor
30
+
31
+ # NOTE: blocking function must be defined at the top level
32
+ # of the module to be able to be pickled and sent to the
33
+ # child processes.
34
+ def blocking_fn():
35
+ sleep(1)
36
+ return 42
37
+
38
+ async def main():
39
+ executor = ProcessPoolExecutor()
40
+ the_answer = await executor.submit(blocking_fn)
41
+ print("The answer is:", the_answer)
42
+
43
+ asyncio.run(main())
44
+ """
45
+
21
46
  DEFAULT_MAX_WORKERS = max((cpu_count(), 4))
22
47
 
23
48
  def __init__(self, max_workers: int = DEFAULT_MAX_WORKERS, **kwargs: Any):
49
+ """
50
+ Initializes a new ProcessPoolExecutor instance.
51
+
52
+ * ``max_workers``:
53
+ The maximum number of processes that can be used to
54
+ execute the given calls. If None or not given then
55
+ as many worker processes will be created as the
56
+ machine has processors.
57
+ * ``mp_context``:
58
+ A multiprocessing context to launch the workers. This
59
+ object should provide SimpleQueue, Queue and Process.
60
+ Useful to allow specific multiprocessing start methods.
61
+ * ``initializer``:
62
+ A callable used to initialize worker processes.
63
+ * ``initargs``:
64
+ A tuple of arguments to pass to the initializer.
65
+ * ``max_tasks_per_child``:
66
+ The maximum number of tasks a worker process
67
+ can complete before it will exit and be replaced
68
+ with a fresh worker process. The default of None
69
+ means worker process will live as long as the
70
+ executor. Requires a non-'fork' mp_context start
71
+ method. When given, we default to using 'spawn'
72
+ if no mp_context is supplied.
73
+ """
24
74
  super().__init__(max_workers=max_workers, **kwargs)
25
75
  self._statistic = ProcessPoolStatistic()
26
76
  self._statistic.processes = max_workers
@@ -31,6 +81,9 @@ class ProcessPoolExecutor(ProcessPoolExecutorBase, EventLoopMixin):
31
81
  start_time: float,
32
82
  loop: asyncio.AbstractEventLoop,
33
83
  ) -> None:
84
+ """
85
+ Callback for statistic
86
+ """
34
87
  if future.exception():
35
88
  self._statistic.error += 1
36
89
  else:
@@ -52,4 +105,7 @@ class ProcessPoolExecutor(ProcessPoolExecutorBase, EventLoopMixin):
52
105
  return future
53
106
 
54
107
  def __del__(self) -> None:
108
+ """
109
+ Cleanup resources
110
+ """
55
111
  self.shutdown()
aiomisc/recurring.py CHANGED
@@ -48,14 +48,14 @@ class RecurringCallback:
48
48
 
49
49
  def __init__(
50
50
  self, coroutine_func: CallbackType,
51
- *args: Any, **kwargs: Any,
51
+ *args: Any, name: Optional[str] = None, **kwargs: Any,
52
52
  ):
53
53
  self.func: Callable[..., Awaitable[Any]]
54
54
  self.args: Tuple[Any, ...]
55
55
  self.kwargs: Mapping[str, Any]
56
56
  self._statistic: RecurringCallbackStatistic
57
57
 
58
- self.name: str = repr(coroutine_func)
58
+ self.name: str = name or repr(coroutine_func)
59
59
  self._statistic = RecurringCallbackStatistic(name=self.name)
60
60
  self.func = utils.awaitable(coroutine_func)
61
61
  self.args = args
@@ -15,9 +15,9 @@ class PeriodicService(Service):
15
15
  interval: Union[int, float]
16
16
  delay: Union[int, float] = 0
17
17
 
18
- def __init__(self, **kwargs: Any):
18
+ def __init__(self, *, name: Optional[str] = None, **kwargs: Any):
19
19
  super().__init__(**kwargs)
20
- self.periodic = PeriodicCallback(self.callback)
20
+ self.periodic = PeriodicCallback(self.callback, name=name)
21
21
 
22
22
  async def start(self) -> None:
23
23
  assert self.interval, f"Interval illegal interval {self.interval!r}"
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, 7, 1)
6
- __version__ = "17.7.1"
5
+ version_info = (17, 7, 5)
6
+ __version__ = "17.7.5"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aiomisc
3
- Version: 17.7.1
3
+ Version: 17.7.5
4
4
  Summary: aiomisc - miscellaneous utils for asyncio
5
5
  License: MIT
6
6
  Author: Dmitry Orlov
@@ -15,9 +15,9 @@ aiomisc/periodic.py,sha256=OFYZbPkcGgeMjBk8zwsLr2TqPRTS6MNewaL3q9qK5js,2252
15
15
  aiomisc/plugins/__init__.py,sha256=eHKGec_217rBjXGf8u-Joyf7dzpO1O0QAuFan1IEyYE,1057
16
16
  aiomisc/plugins/__main__.py,sha256=y3mykRQmimDRHb_PvY4n08vegjWTjd9CONFbCecAxxw,1365
17
17
  aiomisc/pool.py,sha256=kmTEziX7U1kXxmNsTEain9Jkzn8ZbFubuCYWaozZoRk,5764
18
- aiomisc/process_pool.py,sha256=tYSWEXxCP-QXum2TFhyQzyvg86JUSo7EUcrCI7si2-c,1614
18
+ aiomisc/process_pool.py,sha256=3O5FSIVQ6r-jf07Oyjs8Zt0wTL6cNZpV-tENwuQB63Y,3468
19
19
  aiomisc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- aiomisc/recurring.py,sha256=LJ13P_OhZM6mVOed8iUrS-M9PXY12516XBZcFtO7XtI,4923
20
+ aiomisc/recurring.py,sha256=KjqirbRscmNUk53xn0zyGCq2hmQZkceLERJngRyrzNQ,4959
21
21
  aiomisc/service/__init__.py,sha256=_JSkI4Q78UljG4CvhK6He2UGLxJaQS6cVwZ9QT0cSWo,607
22
22
  aiomisc/service/aiohttp.py,sha256=Lfw1dm77zscBZP0H4sKYlVye7RfE0EPWeSSX5V-mvD0,4091
23
23
  aiomisc/service/asgi.py,sha256=S6ejgg7GpHfUzuj46g8QuLXTHn0YWwqI_pAGbXfoNjE,1583
@@ -31,7 +31,7 @@ aiomisc/service/dns/store.py,sha256=PCYp-H1UoFzUVaYfSnK78_TG3fw1CeIzg-ndMgu_cE4,
31
31
  aiomisc/service/dns/tree.py,sha256=q9VRcVxggrClUHyGZZqqSByMaHdU4nYPC1NdT17cVWM,1575
32
32
  aiomisc/service/dns/zone.py,sha256=6Xmrl_leLalSiRQWWNuwGtZVw31Y93i9K2j0JU1vt-4,2174
33
33
  aiomisc/service/grpc_server.py,sha256=G1iRGX3jAfv3fpzNnw_n6UuhORmIZK4cz6aAi7t7qcU,4553
34
- aiomisc/service/periodic.py,sha256=BEKGWxWDOX11sfo7MFYp-hiB5iZ4-c2BRsjS56k5B-0,1241
34
+ aiomisc/service/periodic.py,sha256=Q871Kw6L_L4EDKVl_0pJI2eLWpAjwYs9FnLKeCc9lBY,1283
35
35
  aiomisc/service/process.py,sha256=mZf8muZJNWQo95pUmzchMk08MJMhLifFK8m4CnNX49k,4477
36
36
  aiomisc/service/profiler.py,sha256=6KiJsU7tD5eO4YKZXYujV2E8P-G8GUqLAGIl0AuPNG4,1503
37
37
  aiomisc/service/raven.py,sha256=VHqnXWx-_r71_pjFniIB_E4CgT2reuRD1EB4yEC0hzE,12214
@@ -45,7 +45,7 @@ aiomisc/signal.py,sha256=_iiC2jukXg7-LLirIl1YATlKIIsKLbmTNFr1Ezheu7g,1728
45
45
  aiomisc/thread_pool.py,sha256=591u5HV1aBmBRcaVm4kAtMLPZOb6veqhT9wkts_knqE,14017
46
46
  aiomisc/timeout.py,sha256=5jNDooLW4MAe6ZUIKhkiX29CoyI0zlXd-dZoZwQPxak,920
47
47
  aiomisc/utils.py,sha256=6yTfTpeRCVzfZp-MJCmB1oayOHUBVwQwzC3U5PBAjn8,11919
48
- aiomisc/version.py,sha256=ilCS52JKzZl7hvZBGb2kc1YcDTr33fTbVWDUYneN5D4,154
48
+ aiomisc/version.py,sha256=8FWFY2OsZehRQ96kno-8V30CZiUv1mszZ4ccoyij48I,154
49
49
  aiomisc/worker_pool.py,sha256=GA91KdOrBlqHthbVSTxu_d6BsBIbl-uKqW2NxqSafG0,11107
50
50
  aiomisc_log/__init__.py,sha256=N3g8Ea1YE2dWPDd-MwohuAn3Y0pBxSyL4l4Jsxqkv0Q,4854
51
51
  aiomisc_log/enum.py,sha256=_zfCZPYCGyI9KL6TqHiYVlOfA5U5MCbsuCuDKxDHdxg,1549
@@ -63,8 +63,8 @@ aiomisc_worker/process_inner.py,sha256=8ZtjCSLrgySW57OIbuGrpEWxfysRLYKx1or1YaAqx
63
63
  aiomisc_worker/protocol.py,sha256=1smmlBbdreSmnrxuhHaUMUC10FO9xMIEcedhweQJX_A,2705
64
64
  aiomisc_worker/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  aiomisc_worker/worker.py,sha256=f8nCFhlKh84UUBUaEgCllwMRvVZiD8_UUXaeit6g3T8,3236
66
- aiomisc-17.7.1.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
67
- aiomisc-17.7.1.dist-info/METADATA,sha256=LO9OgOb81BQZvB91ZWZp_T-p3piEI4ASpJOgSJu0baQ,15685
68
- aiomisc-17.7.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
69
- aiomisc-17.7.1.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
70
- aiomisc-17.7.1.dist-info/RECORD,,
66
+ aiomisc-17.7.5.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
67
+ aiomisc-17.7.5.dist-info/METADATA,sha256=7dISlxwcKVqF6kKOhpWI-mWXecHOvXzOPO5a4wQOQGI,15685
68
+ aiomisc-17.7.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
69
+ aiomisc-17.7.5.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
70
+ aiomisc-17.7.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.1
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any