mm-std 0.3.19__py3-none-any.whl → 0.3.20__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.
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  from collections.abc import Awaitable
5
5
  from dataclasses import dataclass
6
+ from logging import Logger
6
7
  from typing import Any
7
8
 
8
9
 
@@ -26,17 +27,21 @@ class AsyncTaskRunner:
26
27
  task_id: str
27
28
  awaitable: Awaitable[Any]
28
29
 
29
- def __init__(self, max_concurrent_tasks: int, timeout: float | None = None, name: str | None = None) -> None:
30
+ def __init__(
31
+ self, max_concurrent_tasks: int, timeout: float | None = None, name: str | None = None, logger: Logger | None = None
32
+ ) -> None:
30
33
  """
31
34
  :param max_concurrent_tasks: Maximum number of tasks that can run concurrently.
32
35
  :param timeout: Optional overall timeout in seconds for running all tasks.
33
36
  :param name: Optional name for the runner.
37
+ :param logger: Optional logger for task exceptions.
34
38
  """
35
39
  if timeout is not None and timeout <= 0:
36
40
  raise ValueError("Timeout must be positive if specified.")
37
41
  self.max_concurrent_tasks: int = max_concurrent_tasks
38
42
  self.timeout: float | None = timeout
39
43
  self.name = name
44
+ self.logger = logger
40
45
  self.semaphore: asyncio.Semaphore = asyncio.Semaphore(max_concurrent_tasks)
41
46
  self._tasks: list[AsyncTaskRunner.Task] = []
42
47
  self._was_run: bool = False
@@ -92,6 +97,8 @@ class AsyncTaskRunner:
92
97
  res: Any = await task.awaitable
93
98
  results[task.task_id] = res
94
99
  except Exception as e:
100
+ if self.logger:
101
+ self.logger.exception(f"Task '{self._task_name(task.task_id)}' raised an exception")
95
102
  exceptions[task.task_id] = e
96
103
 
97
104
  # Create asyncio tasks for all runner tasks
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-std
3
- Version: 0.3.19
3
+ Version: 0.3.20
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: aiohttp-socks~=0.10.1
6
6
  Requires-Dist: aiohttp~=3.11.14
@@ -21,10 +21,10 @@ mm_std/zip.py,sha256=axzF1BwcIygtfNNTefZH7hXKaQqwe-ZH3ChuRWr9dnk,396
21
21
  mm_std/concurrency/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  mm_std/concurrency/async_decorators.py,sha256=xEpyipzp3ZhaPHtdeTE-Ikrt67SUTFKBE6LQPeoeh6Q,1735
23
23
  mm_std/concurrency/async_scheduler.py,sha256=qS3QKMA0xpoxCZWjDW1ItAwKMTQ5h8esXMMRA0eXtxE,5644
24
- mm_std/concurrency/async_task_runner.py,sha256=hO_8umGGKVKfQW_hCzy6Nt0OIBDj7Yfjb8d7CCkmtJU,4643
24
+ mm_std/concurrency/async_task_runner.py,sha256=KyTp4aHt-qBc-qJpXIutFaTP9ykupG7uKafghAwbBvg,4948
25
25
  mm_std/concurrency/sync_decorators.py,sha256=syCQBOmN7qPO55yzgJB2rbkh10CVww376hmyvs6e5tA,1080
26
26
  mm_std/concurrency/sync_scheduler.py,sha256=j4tBL_cBI1spr0cZplTA7N2CoYsznuORMeRN8rpR6gY,2407
27
27
  mm_std/concurrency/sync_task_runner.py,sha256=s5JPlLYLGQGHIxy4oDS-PN7O9gcy-yPZFoNm8RQwzcw,1780
28
- mm_std-0.3.19.dist-info/METADATA,sha256=DXiV1MyhCD0Hn5tRZYdA9wQPoLutkvLX-d_q_CjJ-Co,415
29
- mm_std-0.3.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
- mm_std-0.3.19.dist-info/RECORD,,
28
+ mm_std-0.3.20.dist-info/METADATA,sha256=bcvPFhVCzwNBhB8qz0DW1AZY_jeKqdFIuMiOHHz-22I,415
29
+ mm_std-0.3.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
+ mm_std-0.3.20.dist-info/RECORD,,