mm-std 0.3.11__py3-none-any.whl → 0.3.13__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.
mm_std/async_concurrency.py
CHANGED
@@ -23,6 +23,7 @@ class AsyncScheduler:
|
|
23
23
|
args: Args = ()
|
24
24
|
kwargs: Kwargs = field(default_factory=dict)
|
25
25
|
run_count: int = 0
|
26
|
+
error_count: int = 0
|
26
27
|
last_run: datetime | None = None
|
27
28
|
running: bool = False
|
28
29
|
|
@@ -50,6 +51,7 @@ class AsyncScheduler:
|
|
50
51
|
try:
|
51
52
|
await task.func(*task.args, **task.kwargs)
|
52
53
|
except Exception:
|
54
|
+
task.error_count += 1
|
53
55
|
self._logger.exception("AsyncScheduler exception")
|
54
56
|
|
55
57
|
# Calculate elapsed time and sleep if needed so that tasks never overlap.
|
@@ -71,7 +73,7 @@ class AsyncScheduler:
|
|
71
73
|
while self._running: # noqa: ASYNC110
|
72
74
|
await anyio.sleep(0.1)
|
73
75
|
except anyio.get_cancelled_exc_class():
|
74
|
-
self._logger.
|
76
|
+
self._logger.debug("Task group cancelled. Exiting _start_all_tasks.")
|
75
77
|
|
76
78
|
def start(self) -> None:
|
77
79
|
"""
|
@@ -81,11 +83,11 @@ class AsyncScheduler:
|
|
81
83
|
which runs an AnyIO event loop.
|
82
84
|
"""
|
83
85
|
if self._running:
|
84
|
-
self._logger.warning("
|
86
|
+
self._logger.warning("AsyncScheduler already running")
|
85
87
|
return
|
86
88
|
self._running = True
|
87
|
-
self._logger.
|
88
|
-
self._thread = threading.Thread(target=lambda: anyio.run(self._start_all_tasks), daemon=True)
|
89
|
+
self._logger.debug("Starting AsyncScheduler")
|
90
|
+
self._thread = threading.Thread(target=lambda: anyio.run(self._start_all_tasks), daemon=True, name="AsyncScheduler")
|
89
91
|
self._thread.start()
|
90
92
|
|
91
93
|
def stop(self) -> None:
|
@@ -96,9 +98,9 @@ class AsyncScheduler:
|
|
96
98
|
This method then waits for the background thread to finish.
|
97
99
|
"""
|
98
100
|
if not self._running:
|
99
|
-
self._logger.warning("
|
101
|
+
self._logger.warning("AsyncScheduler not running")
|
100
102
|
return
|
101
|
-
self._logger.
|
103
|
+
self._logger.debug("Stopping AsyncScheduler")
|
102
104
|
self._running = False
|
103
105
|
if self._cancel_scope is not None:
|
104
106
|
self._cancel_scope.cancel()
|
@@ -106,7 +108,7 @@ class AsyncScheduler:
|
|
106
108
|
if self._thread:
|
107
109
|
self._thread.join(timeout=5)
|
108
110
|
self._thread = None
|
109
|
-
self._logger.
|
111
|
+
self._logger.debug("AsyncScheduler stopped")
|
110
112
|
|
111
113
|
|
112
114
|
P = ParamSpec("P")
|
@@ -1,5 +1,5 @@
|
|
1
1
|
mm_std/__init__.py,sha256=BJzVoqux6-YWxGMyXJS34v6CgKh3V7SrpV7eXIUVfbw,2718
|
2
|
-
mm_std/async_concurrency.py,sha256=
|
2
|
+
mm_std/async_concurrency.py,sha256=q4I2NWbm6HkGLg2sWaUDitp4J02zMCopT5CLueEfdu8,4432
|
3
3
|
mm_std/command.py,sha256=ze286wjUjg0QSTgIu-2WZks53_Vclg69UaYYgPpQvCU,1283
|
4
4
|
mm_std/concurrency.py,sha256=4kKLhde6YQYsjJJjH6K5eMQj6FtegEz55Mo5TmhQMM0,5242
|
5
5
|
mm_std/config.py,sha256=4ox4D2CgGR76bvZ2n2vGQOYUDagFnlKEDb87to5zpxE,1871
|
@@ -20,6 +20,6 @@ mm_std/str.py,sha256=BEjJ1p5O4-uSYK0h-enasSSDdwzkBbiwdQ4_dsrlEE8,3257
|
|
20
20
|
mm_std/toml.py,sha256=CNznWKR0bpOxS6e3VB5LGS-Oa9lW-wterkcPUFtPcls,610
|
21
21
|
mm_std/types_.py,sha256=hvZlnvBWyB8CL_MeEWWD0Y0nN677plibYn3yD-5g7xs,99
|
22
22
|
mm_std/zip.py,sha256=axzF1BwcIygtfNNTefZH7hXKaQqwe-ZH3ChuRWr9dnk,396
|
23
|
-
mm_std-0.3.
|
24
|
-
mm_std-0.3.
|
25
|
-
mm_std-0.3.
|
23
|
+
mm_std-0.3.13.dist-info/METADATA,sha256=XdH9K24MAS1uaQejsI0BU7TbX7yofF8E5_xUbfe-WcQ,410
|
24
|
+
mm_std-0.3.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
25
|
+
mm_std-0.3.13.dist-info/RECORD,,
|
File without changes
|