dycw-utilities 0.126.12__py3-none-any.whl → 0.127.0__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.126.12
3
+ Version: 0.127.0
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,6 +1,6 @@
1
- utilities/__init__.py,sha256=w7Bw5b1ygtU74n1HhymesHdGAgm2zjsVhaI-oN62x8k,61
1
+ utilities/__init__.py,sha256=9_7tk0nJkuN-6qR4z_kQd3QZb3ioRi15dhZGN0m-284,60
2
2
  utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
3
- utilities/asyncio.py,sha256=phbGti22VSe9cu-SwM1vP8kyUg8AUDHvvciMvE6JnCg,51842
3
+ utilities/asyncio.py,sha256=wKxwNnxdWxsiy5U0b1F3UgpWRHlPKM0y_OcmURzqxR8,51396
4
4
  utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
5
5
  utilities/atools.py,sha256=IYMuFSFGSKyuQmqD6v5IUtDlz8PPw0Sr87Cub_gRU3M,1168
6
6
  utilities/cachetools.py,sha256=C1zqOg7BYz0IfQFK8e3qaDDgEZxDpo47F15RTfJM37Q,2910
@@ -61,14 +61,14 @@ utilities/pytest_regressions.py,sha256=-SVT9647Dg6-JcdsiaDKXe3NdOmmrvGevLKWwGjxq
61
61
  utilities/python_dotenv.py,sha256=iWcnpXbH7S6RoXHiLlGgyuH6udCupAcPd_gQ0eAenQ0,3190
62
62
  utilities/random.py,sha256=lYdjgxB7GCfU_fwFVl5U-BIM_HV3q6_urL9byjrwDM8,4157
63
63
  utilities/re.py,sha256=5J4d8VwIPFVrX2Eb8zfoxImDv7IwiN_U7mJ07wR2Wvs,3958
64
- utilities/redis.py,sha256=pMKJjNI5e0lG-FZh2_idMBBmfgNr53KIGjBquZQOLZc,37556
64
+ utilities/redis.py,sha256=EZgqWeoGpvN-BfCQL93F3rYlfB4U_zhzHCBuZpDmKpo,37157
65
65
  utilities/reprlib.py,sha256=ssYTcBW-TeRh3fhCJv57sopTZHF5FrPyyUg9yp5XBlo,3953
66
66
  utilities/scipy.py,sha256=X6ROnHwiUhAmPhM0jkfEh0-Fd9iRvwiqtCQMOLmOQF8,945
67
67
  utilities/sentinel.py,sha256=3jIwgpMekWgDAxPDA_hXMP2St43cPhciKN3LWiZ7kv0,1248
68
68
  utilities/shelve.py,sha256=HZsMwK4tcIfg3sh0gApx4-yjQnrY4o3V3ZRimvRhoW0,738
69
- utilities/slack_sdk.py,sha256=h2DiVkcFyYcT5zzZOAo6CSith5BBlHUbXeOJSL1neK8,5948
69
+ utilities/slack_sdk.py,sha256=jqQyiYSKseZNdg2lCkvPzrAows9p7kVDDjvEnatioKo,5702
70
70
  utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
71
- utilities/sqlalchemy.py,sha256=rHixzaYl_QHTR1dAhLj15ntiE5kwZWY4MKIr97crDts,39602
71
+ utilities/sqlalchemy.py,sha256=XTZmNKXD9SUbZ7V1xNNxok-0Ej0Cf4ya5pjuIeH-kdg,39388
72
72
  utilities/sqlalchemy_polars.py,sha256=s7hQNep2O5DTgIRXyN_JRQma7a4DAtNd25tshaZW8iw,15490
73
73
  utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
74
74
  utilities/streamlit.py,sha256=U9PJBaKP1IdSykKhPZhIzSPTZsmLsnwbEPZWzNhJPKk,2955
@@ -90,7 +90,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
90
90
  utilities/whenever.py,sha256=jS31ZAY5OMxFxLja_Yo5Fidi87Pd-GoVZ7Vi_teqVDA,16743
91
91
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
92
92
  utilities/zoneinfo.py,sha256=-5j7IQ9nb7gR43rdgA7ms05im-XuqhAk9EJnQBXxCoQ,1874
93
- dycw_utilities-0.126.12.dist-info/METADATA,sha256=T67klINutEoVWEiFhEoBupDjKUnBGBXokIa1or-nWfI,12804
94
- dycw_utilities-0.126.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
- dycw_utilities-0.126.12.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
96
- dycw_utilities-0.126.12.dist-info/RECORD,,
93
+ dycw_utilities-0.127.0.dist-info/METADATA,sha256=bbY-L7Ck2mkOycI3XCTxhqptadPeM716AJz69ryeIXw,12803
94
+ dycw_utilities-0.127.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
+ dycw_utilities-0.127.0.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
96
+ dycw_utilities-0.127.0.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.126.12"
3
+ __version__ = "0.127.0"
utilities/asyncio.py CHANGED
@@ -663,15 +663,6 @@ class InfiniteQueueLooper(InfiniteLooper[THashable], Generic[THashable, _T]):
663
663
  class LooperError(Exception): ...
664
664
 
665
665
 
666
- @dataclass(kw_only=True, slots=True)
667
- class LooperTimeoutError(LooperError):
668
- duration: Duration | None = None
669
-
670
- @override
671
- def __str__(self) -> str:
672
- return "Timeout" if self.duration is None else f"Timeout after {self.duration}"
673
-
674
-
675
666
  @dataclass(kw_only=True, slots=True)
676
667
  class _LooperNoTaskError(LooperError):
677
668
  looper: Looper
@@ -691,7 +682,6 @@ class Looper(Generic[_T]):
691
682
  empty_upon_exit: bool = field(default=False, repr=False)
692
683
  logger: str | None = field(default=None, repr=False)
693
684
  timeout: Duration | None = field(default=None, repr=False)
694
- timeout_error: type[Exception] = field(default=LooperTimeoutError, repr=False)
695
685
  # settings
696
686
  _backoff: float = field(init=False, repr=False)
697
687
  _debug: bool = field(default=False, repr=False)
@@ -757,7 +747,7 @@ class Looper(Generic[_T]):
757
747
  _ = await self._stack.enter_async_context(looper)
758
748
  if self.auto_start:
759
749
  _ = self._debug and self._logger.debug("%s: auto-starting...", self)
760
- with suppress(self.timeout_error):
750
+ with suppress(TimeoutError):
761
751
  await self._task
762
752
  case _ as never:
763
753
  assert_never(never)
@@ -893,7 +883,6 @@ class Looper(Generic[_T]):
893
883
  backoff: Duration | Sentinel = sentinel,
894
884
  logger: str | None | Sentinel = sentinel,
895
885
  timeout: Duration | None | Sentinel = sentinel,
896
- timeout_error: type[Exception] | Sentinel = sentinel,
897
886
  _debug: bool | Sentinel = sentinel,
898
887
  **kwargs: Any,
899
888
  ) -> Self:
@@ -906,7 +895,6 @@ class Looper(Generic[_T]):
906
895
  backoff=backoff,
907
896
  logger=logger,
908
897
  timeout=timeout,
909
- timeout_error=timeout_error,
910
898
  _debug=_debug,
911
899
  **kwargs,
912
900
  )
@@ -1029,7 +1017,7 @@ class Looper(Generic[_T]):
1029
1017
  async def run_looper(self) -> None:
1030
1018
  """Run the looper."""
1031
1019
  try:
1032
- async with timeout_dur(duration=self.timeout, error=self.timeout_error):
1020
+ async with timeout_dur(duration=self.timeout):
1033
1021
  while True:
1034
1022
  if self._is_stopped.is_set():
1035
1023
  _ = self._debug and self._logger.debug("%s: stopped", self)
@@ -1068,6 +1056,8 @@ class Looper(Generic[_T]):
1068
1056
  if error.args[0] == "generator didn't stop after athrow()":
1069
1057
  return
1070
1058
  raise
1059
+ except TimeoutError:
1060
+ pass
1071
1061
 
1072
1062
  async def run_until_empty(self) -> None:
1073
1063
  """Run until the queue is empty."""
@@ -1430,7 +1420,6 @@ __all__ = [
1430
1420
  "InfiniteQueueLooper",
1431
1421
  "Looper",
1432
1422
  "LooperError",
1433
- "LooperTimeoutError",
1434
1423
  "StreamCommandOutput",
1435
1424
  "UniquePriorityQueue",
1436
1425
  "UniqueQueue",
utilities/redis.py CHANGED
@@ -25,13 +25,7 @@ from typing import (
25
25
  from redis.asyncio import Redis
26
26
  from redis.typing import EncodableT
27
27
 
28
- from utilities.asyncio import (
29
- EnhancedQueue,
30
- InfiniteQueueLooper,
31
- Looper,
32
- LooperTimeoutError,
33
- timeout_dur,
34
- )
28
+ from utilities.asyncio import EnhancedQueue, InfiniteQueueLooper, Looper, timeout_dur
35
29
  from utilities.contextlib import suppress_super_object_attribute_error
36
30
  from utilities.datetime import (
37
31
  MILLISECOND,
@@ -702,9 +696,6 @@ class PublishServiceMixin(Generic[_T]):
702
696
  publish_service_empty_upon_exit: bool = field(default=False, repr=False)
703
697
  publish_service_logger: str | None = field(default=None, repr=False)
704
698
  publish_service_timeout: Duration | None = field(default=None, repr=False)
705
- publish_service_timeout_error: type[Exception] = field(
706
- default=LooperTimeoutError, repr=False
707
- )
708
699
  publish_service_debug: bool = field(default=False, repr=False)
709
700
  _is_pending_restart: Event = field(default_factory=Event, init=False, repr=False)
710
701
  # base - publish service
@@ -724,7 +715,6 @@ class PublishServiceMixin(Generic[_T]):
724
715
  empty_upon_exit=self.publish_service_empty_upon_exit,
725
716
  logger=self.publish_service_logger,
726
717
  timeout=self.publish_service_timeout,
727
- timeout_error=self.publish_service_timeout_error,
728
718
  _debug=self.publish_service_debug,
729
719
  # publish service
730
720
  redis=self.publish_service_redis,
@@ -986,9 +976,6 @@ class SubscribeServiceMixin(Generic[_T]):
986
976
  subscribe_service_empty_upon_exit: bool = field(default=False, repr=False)
987
977
  subscribe_service_logger: str | None = field(default=None, repr=False)
988
978
  subscribe_service_timeout: Duration | None = field(default=None, repr=False)
989
- subscribe_service_timeout_error: type[Exception] = field(
990
- default=LooperTimeoutError, repr=False
991
- )
992
979
  subscribe_service_debug: bool = field(default=False, repr=False)
993
980
  # base - looper
994
981
  subscribe_service_redis: Redis
@@ -1009,7 +996,6 @@ class SubscribeServiceMixin(Generic[_T]):
1009
996
  empty_upon_exit=self.subscribe_service_empty_upon_exit,
1010
997
  logger=self.subscribe_service_logger,
1011
998
  timeout=self.subscribe_service_timeout,
1012
- timeout_error=self.subscribe_service_timeout_error,
1013
999
  _debug=self.subscribe_service_debug,
1014
1000
  # subscribe service
1015
1001
  redis=self.subscribe_service_redis,
utilities/slack_sdk.py CHANGED
@@ -7,12 +7,7 @@ from typing import TYPE_CHECKING, Any, Self, override
7
7
 
8
8
  from slack_sdk.webhook.async_client import AsyncWebhookClient
9
9
 
10
- from utilities.asyncio import (
11
- InfiniteQueueLooper,
12
- Looper,
13
- LooperTimeoutError,
14
- timeout_dur,
15
- )
10
+ from utilities.asyncio import InfiniteQueueLooper, Looper, timeout_dur
16
11
  from utilities.datetime import MINUTE, SECOND, datetime_duration_to_float
17
12
  from utilities.functools import cache
18
13
  from utilities.math import safe_round
@@ -94,7 +89,6 @@ class SlackHandlerService(Handler, Looper[str]):
94
89
  backoff: Duration = SECOND,
95
90
  logger: str | None = None,
96
91
  timeout: Duration | None = None,
97
- timeout_error: type[Exception] = LooperTimeoutError,
98
92
  _debug: bool = False,
99
93
  level: int = NOTSET,
100
94
  sender: Callable[[str, str], Coroutine1[None]] = _send_adapter,
@@ -108,7 +102,6 @@ class SlackHandlerService(Handler, Looper[str]):
108
102
  backoff=backoff,
109
103
  logger=logger,
110
104
  timeout=timeout,
111
- timeout_error=timeout_error,
112
105
  _debug=_debug,
113
106
  )
114
107
  Looper.__post_init__(self)
@@ -144,7 +137,6 @@ class SlackHandlerService(Handler, Looper[str]):
144
137
  backoff: Duration | Sentinel = sentinel,
145
138
  logger: str | None | Sentinel = sentinel,
146
139
  timeout: Duration | None | Sentinel = sentinel,
147
- timeout_error: type[Exception] | Sentinel = sentinel,
148
140
  _debug: bool | Sentinel = sentinel,
149
141
  **kwargs: Any,
150
142
  ) -> Self:
@@ -157,7 +149,6 @@ class SlackHandlerService(Handler, Looper[str]):
157
149
  backoff=backoff,
158
150
  logger=logger,
159
151
  timeout=timeout,
160
- timeout_error=timeout_error,
161
152
  _debug=_debug,
162
153
  **kwargs,
163
154
  )
utilities/sqlalchemy.py CHANGED
@@ -57,12 +57,7 @@ from sqlalchemy.orm import (
57
57
  from sqlalchemy.orm.exc import UnmappedClassError
58
58
  from sqlalchemy.pool import NullPool, Pool
59
59
 
60
- from utilities.asyncio import (
61
- InfiniteQueueLooper,
62
- Looper,
63
- LooperTimeoutError,
64
- timeout_dur,
65
- )
60
+ from utilities.asyncio import InfiniteQueueLooper, Looper, timeout_dur
66
61
  from utilities.contextlib import suppress_super_object_attribute_error
67
62
  from utilities.datetime import SECOND
68
63
  from utilities.functions import (
@@ -707,9 +702,6 @@ class UpsertServiceMixin:
707
702
  upsert_service_empty_upon_exit: bool = field(default=False, repr=False)
708
703
  upsert_service_logger: str | None = field(default=None, repr=False)
709
704
  upsert_service_timeout: Duration | None = field(default=None, repr=False)
710
- upsert_service_timeout_error: type[Exception] = field(
711
- default=LooperTimeoutError, repr=False
712
- )
713
705
  upsert_service_debug: bool = field(default=False, repr=False)
714
706
  # base - upsert service
715
707
  upsert_service_database: AsyncEngine
@@ -734,7 +726,6 @@ class UpsertServiceMixin:
734
726
  empty_upon_exit=self.upsert_service_empty_upon_exit,
735
727
  logger=self.upsert_service_logger,
736
728
  timeout=self.upsert_service_timeout,
737
- timeout_error=self.upsert_service_timeout_error,
738
729
  _debug=self.upsert_service_debug,
739
730
  # upsert service
740
731
  engine=self.upsert_service_database,