dycw-utilities 0.125.22__py3-none-any.whl → 0.125.24__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.
- {dycw_utilities-0.125.22.dist-info → dycw_utilities-0.125.24.dist-info}/METADATA +1 -1
- {dycw_utilities-0.125.22.dist-info → dycw_utilities-0.125.24.dist-info}/RECORD +6 -6
- utilities/__init__.py +1 -1
- utilities/asyncio.py +16 -0
- {dycw_utilities-0.125.22.dist-info → dycw_utilities-0.125.24.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.125.22.dist-info → dycw_utilities-0.125.24.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=WpvBRRRg9E0dopLOUcZu11h6cdS3FNrVVkS3L8r2LCU,61
|
2
2
|
utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
|
3
|
-
utilities/asyncio.py,sha256=
|
3
|
+
utilities/asyncio.py,sha256=qdhfPAKgeJEOKDN2xQbR35dpvYZSWUUqLhHNJEd-pv0,51733
|
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
|
@@ -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.125.
|
94
|
-
dycw_utilities-0.125.
|
95
|
-
dycw_utilities-0.125.
|
96
|
-
dycw_utilities-0.125.
|
93
|
+
dycw_utilities-0.125.24.dist-info/METADATA,sha256=PTMh4H329ZNF8vQUXJ4Z62OIxQ_NrfmL2jBxEhjvuS0,12852
|
94
|
+
dycw_utilities-0.125.24.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
95
|
+
dycw_utilities-0.125.24.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.125.24.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/asyncio.py
CHANGED
@@ -688,6 +688,7 @@ class Looper(Generic[_T]):
|
|
688
688
|
auto_start: bool = field(default=False, repr=False)
|
689
689
|
freq: Duration = field(default=SECOND, repr=False)
|
690
690
|
backoff: Duration = field(default=10 * SECOND, repr=False)
|
691
|
+
empty_upon_exit: bool = field(default=False, repr=False)
|
691
692
|
logger: str | None = field(default=None, repr=False)
|
692
693
|
timeout: Duration | None = field(default=None, repr=False)
|
693
694
|
timeout_error: type[Exception] = field(default=LooperTimeoutError, repr=False)
|
@@ -791,6 +792,8 @@ class Looper(Generic[_T]):
|
|
791
792
|
)
|
792
793
|
_ = await self._stack.__aexit__(exc_type, exc_value, traceback)
|
793
794
|
await self.stop()
|
795
|
+
if self.empty_upon_exit:
|
796
|
+
await self.run_until_empty()
|
794
797
|
case False:
|
795
798
|
_ = self._debug and self._logger.debug("%s: already exited", self)
|
796
799
|
case _ as never:
|
@@ -891,19 +894,25 @@ class Looper(Generic[_T]):
|
|
891
894
|
self,
|
892
895
|
*,
|
893
896
|
auto_start: bool | Sentinel = sentinel,
|
897
|
+
empty_upon_exit: bool | Sentinel = sentinel,
|
894
898
|
freq: Duration | Sentinel = sentinel,
|
895
899
|
backoff: Duration | Sentinel = sentinel,
|
896
900
|
logger: str | None | Sentinel = sentinel,
|
897
901
|
timeout: Duration | None | Sentinel = sentinel,
|
902
|
+
timeout_error: type[Exception] | Sentinel = sentinel,
|
903
|
+
_debug: bool | Sentinel = sentinel,
|
898
904
|
) -> Self:
|
899
905
|
"""Replace elements of the looper."""
|
900
906
|
return replace_non_sentinel(
|
901
907
|
self,
|
902
908
|
auto_start=auto_start,
|
909
|
+
empty_upon_exit=empty_upon_exit,
|
903
910
|
freq=freq,
|
904
911
|
backoff=backoff,
|
905
912
|
logger=logger,
|
906
913
|
timeout=timeout,
|
914
|
+
timeout_error=timeout_error,
|
915
|
+
_debug=_debug,
|
907
916
|
)
|
908
917
|
|
909
918
|
def request_restart(self) -> None:
|
@@ -1057,6 +1066,13 @@ class Looper(Generic[_T]):
|
|
1057
1066
|
self._core_successes += 1
|
1058
1067
|
await sleep(self._freq)
|
1059
1068
|
|
1069
|
+
async def run_until_empty(self) -> None:
|
1070
|
+
"""Run until the queue is empty."""
|
1071
|
+
while not self.empty():
|
1072
|
+
await self.core()
|
1073
|
+
if not self.empty():
|
1074
|
+
await sleep(self._freq)
|
1075
|
+
|
1060
1076
|
@property
|
1061
1077
|
def stats(self) -> _LooperStats:
|
1062
1078
|
"""Return the statistics."""
|
File without changes
|
File without changes
|