ez-a-sync 0.32.29__cp310-cp310-win_amd64.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.
Potentially problematic release.
This version of ez-a-sync might be problematic. Click here for more details.
- a_sync/ENVIRONMENT_VARIABLES.py +42 -0
- a_sync/__init__.pxd +2 -0
- a_sync/__init__.py +145 -0
- a_sync/_smart.c +22803 -0
- a_sync/_smart.cp310-win_amd64.pyd +0 -0
- a_sync/_smart.pxd +2 -0
- a_sync/_smart.pyi +202 -0
- a_sync/_smart.pyx +674 -0
- a_sync/_typing.py +258 -0
- a_sync/a_sync/__init__.py +60 -0
- a_sync/a_sync/_descriptor.c +20528 -0
- a_sync/a_sync/_descriptor.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/_descriptor.pyi +33 -0
- a_sync/a_sync/_descriptor.pyx +422 -0
- a_sync/a_sync/_flags.c +6074 -0
- a_sync/a_sync/_flags.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/_flags.pxd +3 -0
- a_sync/a_sync/_flags.pyx +92 -0
- a_sync/a_sync/_helpers.c +14521 -0
- a_sync/a_sync/_helpers.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/_helpers.pxd +3 -0
- a_sync/a_sync/_helpers.pyi +10 -0
- a_sync/a_sync/_helpers.pyx +167 -0
- a_sync/a_sync/_kwargs.c +12194 -0
- a_sync/a_sync/_kwargs.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/_kwargs.pxd +2 -0
- a_sync/a_sync/_kwargs.pyx +64 -0
- a_sync/a_sync/_meta.py +210 -0
- a_sync/a_sync/abstract.c +12411 -0
- a_sync/a_sync/abstract.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/abstract.pyi +141 -0
- a_sync/a_sync/abstract.pyx +221 -0
- a_sync/a_sync/base.c +14932 -0
- a_sync/a_sync/base.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/base.pyi +60 -0
- a_sync/a_sync/base.pyx +271 -0
- a_sync/a_sync/config.py +168 -0
- a_sync/a_sync/decorator.py +651 -0
- a_sync/a_sync/flags.c +5272 -0
- a_sync/a_sync/flags.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/flags.pxd +72 -0
- a_sync/a_sync/flags.pyi +74 -0
- a_sync/a_sync/flags.pyx +72 -0
- a_sync/a_sync/function.c +37846 -0
- a_sync/a_sync/function.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/function.pxd +28 -0
- a_sync/a_sync/function.pyi +571 -0
- a_sync/a_sync/function.pyx +1381 -0
- a_sync/a_sync/method.c +29774 -0
- a_sync/a_sync/method.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/method.pxd +9 -0
- a_sync/a_sync/method.pyi +525 -0
- a_sync/a_sync/method.pyx +1023 -0
- a_sync/a_sync/modifiers/__init__.pxd +1 -0
- a_sync/a_sync/modifiers/__init__.py +101 -0
- a_sync/a_sync/modifiers/cache/__init__.py +160 -0
- a_sync/a_sync/modifiers/cache/memory.py +165 -0
- a_sync/a_sync/modifiers/limiter.py +132 -0
- a_sync/a_sync/modifiers/manager.c +16149 -0
- a_sync/a_sync/modifiers/manager.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/modifiers/manager.pxd +5 -0
- a_sync/a_sync/modifiers/manager.pyi +219 -0
- a_sync/a_sync/modifiers/manager.pyx +299 -0
- a_sync/a_sync/modifiers/semaphores.py +173 -0
- a_sync/a_sync/property.c +27260 -0
- a_sync/a_sync/property.cp310-win_amd64.pyd +0 -0
- a_sync/a_sync/property.pyi +376 -0
- a_sync/a_sync/property.pyx +819 -0
- a_sync/a_sync/singleton.py +63 -0
- a_sync/aliases.py +3 -0
- a_sync/async_property/__init__.pxd +1 -0
- a_sync/async_property/__init__.py +1 -0
- a_sync/async_property/cached.c +20386 -0
- a_sync/async_property/cached.cp310-win_amd64.pyd +0 -0
- a_sync/async_property/cached.pxd +10 -0
- a_sync/async_property/cached.pyi +45 -0
- a_sync/async_property/cached.pyx +178 -0
- a_sync/async_property/proxy.c +34654 -0
- a_sync/async_property/proxy.cp310-win_amd64.pyd +0 -0
- a_sync/async_property/proxy.pxd +2 -0
- a_sync/async_property/proxy.pyi +124 -0
- a_sync/async_property/proxy.pyx +474 -0
- a_sync/asyncio/__init__.pxd +6 -0
- a_sync/asyncio/__init__.py +164 -0
- a_sync/asyncio/as_completed.c +18841 -0
- a_sync/asyncio/as_completed.cp310-win_amd64.pyd +0 -0
- a_sync/asyncio/as_completed.pxd +8 -0
- a_sync/asyncio/as_completed.pyi +109 -0
- a_sync/asyncio/as_completed.pyx +269 -0
- a_sync/asyncio/create_task.c +15902 -0
- a_sync/asyncio/create_task.cp310-win_amd64.pyd +0 -0
- a_sync/asyncio/create_task.pxd +2 -0
- a_sync/asyncio/create_task.pyi +51 -0
- a_sync/asyncio/create_task.pyx +271 -0
- a_sync/asyncio/gather.c +16679 -0
- a_sync/asyncio/gather.cp310-win_amd64.pyd +0 -0
- a_sync/asyncio/gather.pyi +107 -0
- a_sync/asyncio/gather.pyx +218 -0
- a_sync/asyncio/igather.c +12676 -0
- a_sync/asyncio/igather.cp310-win_amd64.pyd +0 -0
- a_sync/asyncio/igather.pxd +1 -0
- a_sync/asyncio/igather.pyi +7 -0
- a_sync/asyncio/igather.pyx +182 -0
- a_sync/asyncio/sleep.c +9593 -0
- a_sync/asyncio/sleep.cp310-win_amd64.pyd +0 -0
- a_sync/asyncio/sleep.pyi +14 -0
- a_sync/asyncio/sleep.pyx +49 -0
- a_sync/debugging.c +15362 -0
- a_sync/debugging.cp310-win_amd64.pyd +0 -0
- a_sync/debugging.pyi +76 -0
- a_sync/debugging.pyx +107 -0
- a_sync/exceptions.c +13312 -0
- a_sync/exceptions.cp310-win_amd64.pyd +0 -0
- a_sync/exceptions.pyi +376 -0
- a_sync/exceptions.pyx +446 -0
- a_sync/executor.py +619 -0
- a_sync/functools.c +12738 -0
- a_sync/functools.cp310-win_amd64.pyd +0 -0
- a_sync/functools.pxd +7 -0
- a_sync/functools.pyi +33 -0
- a_sync/functools.pyx +139 -0
- a_sync/future.py +1497 -0
- a_sync/iter.c +37271 -0
- a_sync/iter.cp310-win_amd64.pyd +0 -0
- a_sync/iter.pxd +11 -0
- a_sync/iter.pyi +370 -0
- a_sync/iter.pyx +981 -0
- a_sync/primitives/__init__.pxd +1 -0
- a_sync/primitives/__init__.py +53 -0
- a_sync/primitives/_debug.c +15757 -0
- a_sync/primitives/_debug.cp310-win_amd64.pyd +0 -0
- a_sync/primitives/_debug.pxd +12 -0
- a_sync/primitives/_debug.pyi +52 -0
- a_sync/primitives/_debug.pyx +223 -0
- a_sync/primitives/_loggable.c +11529 -0
- a_sync/primitives/_loggable.cp310-win_amd64.pyd +0 -0
- a_sync/primitives/_loggable.pxd +4 -0
- a_sync/primitives/_loggable.pyi +66 -0
- a_sync/primitives/_loggable.pyx +102 -0
- a_sync/primitives/locks/__init__.pxd +8 -0
- a_sync/primitives/locks/__init__.py +17 -0
- a_sync/primitives/locks/counter.c +17679 -0
- a_sync/primitives/locks/counter.cp310-win_amd64.pyd +0 -0
- a_sync/primitives/locks/counter.pxd +12 -0
- a_sync/primitives/locks/counter.pyi +151 -0
- a_sync/primitives/locks/counter.pyx +260 -0
- a_sync/primitives/locks/event.c +17063 -0
- a_sync/primitives/locks/event.cp310-win_amd64.pyd +0 -0
- a_sync/primitives/locks/event.pxd +22 -0
- a_sync/primitives/locks/event.pyi +43 -0
- a_sync/primitives/locks/event.pyx +185 -0
- a_sync/primitives/locks/prio_semaphore.c +25590 -0
- a_sync/primitives/locks/prio_semaphore.cp310-win_amd64.pyd +0 -0
- a_sync/primitives/locks/prio_semaphore.pxd +25 -0
- a_sync/primitives/locks/prio_semaphore.pyi +217 -0
- a_sync/primitives/locks/prio_semaphore.pyx +597 -0
- a_sync/primitives/locks/semaphore.c +26509 -0
- a_sync/primitives/locks/semaphore.cp310-win_amd64.pyd +0 -0
- a_sync/primitives/locks/semaphore.pxd +21 -0
- a_sync/primitives/locks/semaphore.pyi +197 -0
- a_sync/primitives/locks/semaphore.pyx +454 -0
- a_sync/primitives/queue.py +1022 -0
- a_sync/py.typed +0 -0
- a_sync/sphinx/__init__.py +3 -0
- a_sync/sphinx/ext.py +289 -0
- a_sync/task.py +932 -0
- a_sync/utils/__init__.py +105 -0
- a_sync/utils/iterators.py +297 -0
- a_sync/utils/repr.c +15799 -0
- a_sync/utils/repr.cp310-win_amd64.pyd +0 -0
- a_sync/utils/repr.pyi +2 -0
- a_sync/utils/repr.pyx +73 -0
- ez_a_sync-0.32.29.dist-info/METADATA +367 -0
- ez_a_sync-0.32.29.dist-info/RECORD +177 -0
- ez_a_sync-0.32.29.dist-info/WHEEL +5 -0
- ez_a_sync-0.32.29.dist-info/licenses/LICENSE.txt +17 -0
- ez_a_sync-0.32.29.dist-info/top_level.txt +1 -0
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cdef object cigather(object coros_or_futures, bint return_exceptions=*)
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from asyncio import futures, tasks
|
|
3
|
+
from typing import Awaitable, Iterable, List, TypeVar
|
|
4
|
+
|
|
5
|
+
from cpython.version cimport PY_VERSION_HEX
|
|
6
|
+
|
|
7
|
+
from a_sync import _smart
|
|
8
|
+
from a_sync.a_sync._helpers cimport get_event_loop
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__T = TypeVar("__T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
cdef object current_task = asyncio.current_task
|
|
15
|
+
cdef object ensure_future = asyncio.ensure_future
|
|
16
|
+
cdef object CancelledError = asyncio.CancelledError
|
|
17
|
+
cdef object _get_loop = futures._get_loop
|
|
18
|
+
cdef object _GatheringFuture = tasks._GatheringFuture
|
|
19
|
+
|
|
20
|
+
cdef object smart_task_factory = _smart.smart_task_factory
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def igather(
|
|
24
|
+
coros_or_futures: Iterable[Awaitable[__T]], bint return_exceptions = False
|
|
25
|
+
) -> Awaitable[List[__T]]:
|
|
26
|
+
"""A clone of asyncio.gather that takes a single iterator of coroutines instead of an unpacked tuple."""
|
|
27
|
+
return cigather(coros_or_futures, return_exceptions=return_exceptions)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
cdef object cigather(object coros_or_futures, bint return_exceptions = False):
|
|
31
|
+
"""A clone of asyncio.gather that takes a single iterator of coroutines instead of an unpacked tuple."""
|
|
32
|
+
# NOTE: closures inside cpdef functions not yet supported, so we have this cdef helper
|
|
33
|
+
cdef long long nfuts, nfinished
|
|
34
|
+
cdef dict arg_to_fut = {}
|
|
35
|
+
cdef list children = []
|
|
36
|
+
loop = None
|
|
37
|
+
for arg in coros_or_futures:
|
|
38
|
+
if arg not in arg_to_fut:
|
|
39
|
+
fut = ensure_future(arg, loop=loop)
|
|
40
|
+
if loop is None:
|
|
41
|
+
loop = _get_loop(fut)
|
|
42
|
+
if fut is not arg:
|
|
43
|
+
# 'arg' was not a Future, therefore, 'fut' is a new
|
|
44
|
+
# Future created specifically for 'arg'. Since the caller
|
|
45
|
+
# can't control it, disable the "destroy pending task"
|
|
46
|
+
# warning.
|
|
47
|
+
fut._log_destroy_pending = False
|
|
48
|
+
|
|
49
|
+
arg_to_fut[arg] = fut
|
|
50
|
+
|
|
51
|
+
else:
|
|
52
|
+
# There's a duplicate Future object in coros_or_futures.
|
|
53
|
+
fut = arg_to_fut[arg]
|
|
54
|
+
|
|
55
|
+
children.append(fut)
|
|
56
|
+
|
|
57
|
+
if not children:
|
|
58
|
+
return _get_empty_result_set_fut(get_event_loop())
|
|
59
|
+
|
|
60
|
+
nfuts = len(arg_to_fut)
|
|
61
|
+
nfinished = 0
|
|
62
|
+
outer = None # bpo-46672
|
|
63
|
+
|
|
64
|
+
if return_exceptions:
|
|
65
|
+
|
|
66
|
+
def _done_callback(fut: asyncio.Future) -> None:
|
|
67
|
+
# for some reason this wouldn't work until I added `return_exceptions=return_exceptions` to the func def
|
|
68
|
+
nonlocal nfinished
|
|
69
|
+
nfinished += 1
|
|
70
|
+
|
|
71
|
+
if outer is None or outer.done():
|
|
72
|
+
if not fut.cancelled():
|
|
73
|
+
# Mark exception retrieved.
|
|
74
|
+
fut.exception()
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
if nfinished == nfuts:
|
|
78
|
+
# All futures are done; create a list of results
|
|
79
|
+
# and set it to the 'outer' future.
|
|
80
|
+
|
|
81
|
+
if outer._cancel_requested:
|
|
82
|
+
# If gather is being cancelled we must propagate the
|
|
83
|
+
# cancellation regardless of *return_exceptions* argument.
|
|
84
|
+
# See issue 32684.
|
|
85
|
+
exc = (
|
|
86
|
+
CancelledError()
|
|
87
|
+
if PY_VERSION_HEX < 0x03090000 # Python 3.9
|
|
88
|
+
else fut._make_cancelled_error()
|
|
89
|
+
)
|
|
90
|
+
outer.set_exception(exc)
|
|
91
|
+
else:
|
|
92
|
+
outer.set_result([_get_result_or_exc(child) for child in children])
|
|
93
|
+
|
|
94
|
+
else:
|
|
95
|
+
|
|
96
|
+
def _done_callback(fut: asyncio.Future) -> None:
|
|
97
|
+
# for some reason this wouldn't work until I added `return_exceptions=return_exceptions` to the func def
|
|
98
|
+
nonlocal nfinished
|
|
99
|
+
nfinished += 1
|
|
100
|
+
|
|
101
|
+
if outer is None or outer.done():
|
|
102
|
+
if not fut.cancelled():
|
|
103
|
+
# Mark exception retrieved.
|
|
104
|
+
fut.exception()
|
|
105
|
+
return
|
|
106
|
+
|
|
107
|
+
if fut.cancelled():
|
|
108
|
+
# Check if 'fut' is cancelled first, as
|
|
109
|
+
# 'fut.exception()' will *raise* a CancelledError
|
|
110
|
+
# instead of returning it.
|
|
111
|
+
exc = (
|
|
112
|
+
CancelledError()
|
|
113
|
+
if PY_VERSION_HEX < 0x03090000 # Python 3.9
|
|
114
|
+
else fut._make_cancelled_error()
|
|
115
|
+
)
|
|
116
|
+
outer.set_exception(exc)
|
|
117
|
+
return
|
|
118
|
+
else:
|
|
119
|
+
exc = fut.exception()
|
|
120
|
+
if exc is not None:
|
|
121
|
+
outer.set_exception(exc)
|
|
122
|
+
return
|
|
123
|
+
|
|
124
|
+
if nfinished == nfuts:
|
|
125
|
+
# All futures are done; create a list of results
|
|
126
|
+
# and set it to the 'outer' future.
|
|
127
|
+
|
|
128
|
+
if outer._cancel_requested:
|
|
129
|
+
# If gather is being cancelled we must propagate the
|
|
130
|
+
# cancellation regardless of *return_exceptions* argument.
|
|
131
|
+
# See issue 32684.
|
|
132
|
+
exc = (
|
|
133
|
+
CancelledError()
|
|
134
|
+
if PY_VERSION_HEX < 0x03090000 # Python 3.9
|
|
135
|
+
else fut._make_cancelled_error()
|
|
136
|
+
)
|
|
137
|
+
outer.set_exception(exc)
|
|
138
|
+
else:
|
|
139
|
+
outer.set_result([_get_result_or_exc(child) for child in children])
|
|
140
|
+
|
|
141
|
+
if loop._task_factory is smart_task_factory:
|
|
142
|
+
current = current_task()
|
|
143
|
+
for fut in arg_to_fut.values():
|
|
144
|
+
fut.add_done_callback(_done_callback)
|
|
145
|
+
waiters = getattr(fut, "_waiters", None)
|
|
146
|
+
if waiters is not None:
|
|
147
|
+
waiters.add(current)
|
|
148
|
+
else:
|
|
149
|
+
for fut in arg_to_fut.values():
|
|
150
|
+
fut.add_done_callback(_done_callback)
|
|
151
|
+
|
|
152
|
+
outer = _GatheringFuture(children, loop=loop)
|
|
153
|
+
|
|
154
|
+
return outer
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
cdef dict[object, object] _no_results_futs = {}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
cdef object _get_empty_result_set_fut(loop):
|
|
161
|
+
fut = _no_results_futs.get(loop)
|
|
162
|
+
if fut is None:
|
|
163
|
+
fut = _no_results_futs[loop] = loop.create_future()
|
|
164
|
+
fut.set_result([])
|
|
165
|
+
return fut
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
cdef object _get_result_or_exc(fut: asyncio.Future):
|
|
169
|
+
if fut.cancelled():
|
|
170
|
+
if PY_VERSION_HEX < 0x03090000:
|
|
171
|
+
return CancelledError()
|
|
172
|
+
# Check if 'fut' is cancelled first, as 'fut.exception()'
|
|
173
|
+
# will *raise* a CancelledError instead of returning it.
|
|
174
|
+
# Also, since we're adding the exception return value
|
|
175
|
+
# to 'results' instead of raising it, don't bother
|
|
176
|
+
# setting __context__. This also lets us preserve
|
|
177
|
+
# calling '_make_cancelled_error()' at most once.
|
|
178
|
+
return CancelledError("" if fut._cancel_message is None else fut._cancel_message)
|
|
179
|
+
res = fut.exception()
|
|
180
|
+
if res is None:
|
|
181
|
+
return fut.result()
|
|
182
|
+
return res
|