reykit 1.1.11__py3-none-any.whl → 1.1.12__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.
reykit/rmultitask.py
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from __future__ import annotations
|
13
|
-
from typing import Any, Literal
|
14
|
-
from collections.abc import Callable, Iterable, Generator, Coroutine
|
13
|
+
from typing import Any, Literal, Self
|
14
|
+
from collections.abc import Callable, Iterable, Iterator, Generator, Coroutine, AsyncIterator
|
15
15
|
from threading import RLock as TRLock, get_ident as threading_get_ident
|
16
16
|
from concurrent.futures import ThreadPoolExecutor, Future as CFuture, as_completed as concurrent_as_completed
|
17
17
|
from asyncio import (
|
@@ -36,7 +36,8 @@ __all__ = (
|
|
36
36
|
'RThreadLock',
|
37
37
|
'RAsyncLock',
|
38
38
|
'RThreadPool',
|
39
|
-
'RAsyncPool'
|
39
|
+
'RAsyncPool',
|
40
|
+
'RAsyncIterator'
|
40
41
|
)
|
41
42
|
|
42
43
|
|
@@ -868,3 +869,67 @@ class RAsyncPool(object):
|
|
868
869
|
|
869
870
|
|
870
871
|
__mul__ = repeat
|
872
|
+
|
873
|
+
|
874
|
+
class RAsyncIterator(AsyncIterator):
|
875
|
+
"""
|
876
|
+
Rey's `asynchronous iterator` type.
|
877
|
+
"""
|
878
|
+
|
879
|
+
|
880
|
+
def __init__(
|
881
|
+
self,
|
882
|
+
task: Callable,
|
883
|
+
args_iter: Iterable[Iterable] | None = None,
|
884
|
+
kwargs_iter: Iterable[dict] | None = None
|
885
|
+
) -> None:
|
886
|
+
"""
|
887
|
+
Build `asynchronous iterator` attributes.
|
888
|
+
|
889
|
+
Parameters
|
890
|
+
----------
|
891
|
+
task : Asynchronous task.
|
892
|
+
args_iter : Iterable of task position arguments.
|
893
|
+
kwargs_iter : Iterable of task keyword arguments.
|
894
|
+
"""
|
895
|
+
|
896
|
+
# Set attribute.
|
897
|
+
self.task = task
|
898
|
+
if args_iter is not None:
|
899
|
+
args_iter: Iterator[Iterable] = iter(args_iter)
|
900
|
+
self.args_iter = args_iter
|
901
|
+
if kwargs_iter is not None:
|
902
|
+
kwargs_iter: Iterator[dict] = iter(kwargs_iter)
|
903
|
+
self.kwargs_iter = kwargs_iter
|
904
|
+
|
905
|
+
|
906
|
+
def __aiter__(self) -> Self:
|
907
|
+
"""
|
908
|
+
Get asynchronous iterator.
|
909
|
+
"""
|
910
|
+
|
911
|
+
return self
|
912
|
+
|
913
|
+
|
914
|
+
async def __anext__(self):
|
915
|
+
"""
|
916
|
+
Get next value from asynchronous iterator.
|
917
|
+
"""
|
918
|
+
|
919
|
+
# Get parameter.
|
920
|
+
args = ()
|
921
|
+
kwargs = {}
|
922
|
+
|
923
|
+
## Next.
|
924
|
+
try:
|
925
|
+
if self.args_iter is not None:
|
926
|
+
args = next(self.args_iter)
|
927
|
+
if self.kwargs_iter is not None:
|
928
|
+
kwargs = next(self.kwargs_iter)
|
929
|
+
except StopIteration:
|
930
|
+
raise StopAsyncIteration
|
931
|
+
|
932
|
+
# Execute.
|
933
|
+
result = self.task(*args, **kwargs)
|
934
|
+
|
935
|
+
return result
|
@@ -7,7 +7,7 @@ reykit/rexception.py,sha256=ftXVdEVkU0B0HXbKjQTiJRJVVGbvhorwWtMiplpN9Zk,8118
|
|
7
7
|
reykit/rimage.py,sha256=fQpIHX6Go3Jk_MDgsSDnZx27EZHumyGdgI9xyjP5lYQ,6275
|
8
8
|
reykit/rlog.py,sha256=qhmATMv3_bJRaiuN9mo8hSf_95HH5Lw838aJFio98sg,25760
|
9
9
|
reykit/rmonkey.py,sha256=RqhmKXabl11s2RJaGizpm00Q1yEkul1Je5uxw8_thUk,7584
|
10
|
-
reykit/rmultitask.py,sha256=
|
10
|
+
reykit/rmultitask.py,sha256=5oWApPnOrYrDDDZunTasAf8nmvrwBlKhS63cvSsi1iE,23599
|
11
11
|
reykit/rnumber.py,sha256=XseLDNLDOt-XYP2P9oDbkKYuHudeSoWzIHsOENO8vvE,3196
|
12
12
|
reykit/ros.py,sha256=6fHKCpxoWmCpxlRpGag5E-GzGsh0xt8YEmx9iqDvN_o,40780
|
13
13
|
reykit/rrandom.py,sha256=TfQKYXRw379MMRIZYfjBtCkmsartA9thhDIG1fc3tM4,9233
|
@@ -24,7 +24,7 @@ reykit/rzip.py,sha256=i6KkmeSWCnq025d-O1mbuCYezNRUhyY9OGVK0CRlNAM,3522
|
|
24
24
|
reykit/rdll/__init__.py,sha256=vM9V7wSNno-WH9RrxgHTIgCkQm8LmBFoLFO8z7qovNo,306
|
25
25
|
reykit/rdll/rdll_inject.py,sha256=bETl8tywtN1OiQudbA21u6GwBM_bqVX7jbiisNj_JBg,645
|
26
26
|
reykit/rdll/rdll_inject_core.py,sha256=Trgh_pdJs_Lw-Y-0Kkn8kHr4BnilM9dBKnHnX25T_pM,5092
|
27
|
-
reykit-1.1.
|
28
|
-
reykit-1.1.
|
29
|
-
reykit-1.1.
|
30
|
-
reykit-1.1.
|
27
|
+
reykit-1.1.12.dist-info/METADATA,sha256=5mIrvjJ0mmU7omM998GB5RHL566x2lfhXgIN3ZKuHSk,1889
|
28
|
+
reykit-1.1.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
29
|
+
reykit-1.1.12.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
30
|
+
reykit-1.1.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|