dycw-utilities 0.134.3__py3-none-any.whl → 0.134.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.134.3
3
+ Version: 0.134.4
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,8 +1,8 @@
1
- utilities/__init__.py,sha256=Ayw_2oayPW-WIP3bGtbUE6g3SFitrjRG5_og7H0SmV8,60
1
+ utilities/__init__.py,sha256=aGENX9jJ-5Lnfpi2UfGD4tuv49MbTmIMv6OGK_-O8lM,60
2
2
  utilities/aiolimiter.py,sha256=mD0wEiqMgwpty4XTbawFpnkkmJS6R4JRsVXFUaoitSU,628
3
3
  utilities/altair.py,sha256=HeZBVUocjkrTNwwKrClppsIqgNFF-ykv05HfZSoHYno,9104
4
4
  utilities/arq.py,sha256=S-sfBfY-E1ErRKf4sSXt2YyCjKvu-pBlOECDfjBebRA,6399
5
- utilities/asyncio.py,sha256=F12PF2z0letHzFhESXLlAYLTSV7MpTAGfW8FF3EWFmM,37403
5
+ utilities/asyncio.py,sha256=qqoV2xXrZoOw1ck9yHOh8mxlnoh96Huwd5xGmJcu3fQ,38165
6
6
  utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
7
7
  utilities/atools.py,sha256=9im2g8OCf-Iynqa8bAv8N0Ycj9QvrJmGO7yLCZEdgII,986
8
8
  utilities/cachetools.py,sha256=v1-9sXHLdOLiwmkq6NB0OUbxeKBuVVN6wmAWefWoaHI,2744
@@ -90,7 +90,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
90
90
  utilities/whenever.py,sha256=A-yoOqBqrcVD1yDINDsTFDw7dq9-zgUGn_f8CxVUQJs,23332
91
91
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
92
92
  utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
93
- dycw_utilities-0.134.3.dist-info/METADATA,sha256=asf6ss3pPJEYGfENxbgJ4xgaihG7bK8FFO3Nbc3mMaQ,1584
94
- dycw_utilities-0.134.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
- dycw_utilities-0.134.3.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
96
- dycw_utilities-0.134.3.dist-info/RECORD,,
93
+ dycw_utilities-0.134.4.dist-info/METADATA,sha256=bayiwKsZUr-VMVW1EI2cLFL3rbWrqqftZXA1PrXoe3c,1584
94
+ dycw_utilities-0.134.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
+ dycw_utilities-0.134.4.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
96
+ dycw_utilities-0.134.4.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.134.3"
3
+ __version__ = "0.134.4"
utilities/asyncio.py CHANGED
@@ -223,6 +223,7 @@ class EnhancedTaskGroup(TaskGroup):
223
223
  _semaphore: Semaphore | None
224
224
  _timeout: TimeDelta | None
225
225
  _error: MaybeType[BaseException]
226
+ _debug: bool
226
227
  _stack: AsyncExitStack
227
228
  _timeout_cm: _AsyncGeneratorContextManager[None] | None
228
229
 
@@ -233,11 +234,13 @@ class EnhancedTaskGroup(TaskGroup):
233
234
  max_tasks: int | None = None,
234
235
  timeout: TimeDelta | None = None,
235
236
  error: MaybeType[BaseException] = TimeoutError,
237
+ debug: bool = False,
236
238
  ) -> None:
237
239
  super().__init__()
238
240
  self._semaphore = None if max_tasks is None else Semaphore(max_tasks)
239
241
  self._timeout = timeout
240
242
  self._error = error
243
+ self._debug = debug
241
244
  self._stack = AsyncExitStack()
242
245
  self._timeout_cm = None
243
246
 
@@ -254,7 +257,14 @@ class EnhancedTaskGroup(TaskGroup):
254
257
  tb: TracebackType | None,
255
258
  ) -> None:
256
259
  _ = await self._stack.__aexit__(et, exc, tb)
257
- _ = await super().__aexit__(et, exc, tb)
260
+ match self._debug:
261
+ case True:
262
+ with suppress(Exception):
263
+ _ = await super().__aexit__(et, exc, tb)
264
+ case False:
265
+ _ = await super().__aexit__(et, exc, tb)
266
+ case _ as never:
267
+ assert_never(never)
258
268
 
259
269
  @override
260
270
  def create_task[T](
@@ -276,6 +286,21 @@ class EnhancedTaskGroup(TaskGroup):
276
286
  _ = self._stack.push_async_callback(cm.__aexit__, None, None, None)
277
287
  return self.create_task(cm.__aenter__())
278
288
 
289
+ async def run_or_create_task[T](
290
+ self,
291
+ coro: _CoroutineLike[T],
292
+ *,
293
+ name: str | None = None,
294
+ context: Context | None = None,
295
+ ) -> T | Task[T]:
296
+ match self._debug:
297
+ case True:
298
+ return await coro
299
+ case False:
300
+ return self.create_task(coro, name=name, context=context)
301
+ case _ as never:
302
+ assert_never(never)
303
+
279
304
  async def _wrap_with_semaphore[T](
280
305
  self, semaphore: Semaphore, coroutine: _CoroutineLike[T], /
281
306
  ) -> T: