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
|
a_sync/_smart.pxd
ADDED
a_sync/_smart.pyi
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
from asyncio import AbstractEventLoop, Future, Task
|
|
2
|
+
from typing import TYPE_CHECKING, Any, Awaitable, Generic, Optional, Tuple, TypeVar, Union
|
|
3
|
+
from weakref import WeakSet
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from a_sync.primitives.queue import SmartProcessingQueue
|
|
7
|
+
|
|
8
|
+
_T = TypeVar("_T")
|
|
9
|
+
|
|
10
|
+
_Args = Tuple[Any]
|
|
11
|
+
_Kwargs = Tuple[Tuple[str, Any]]
|
|
12
|
+
_Key = Tuple[_Args, _Kwargs]
|
|
13
|
+
|
|
14
|
+
def shield(arg: Awaitable[_T]) -> Union[SmartFuture[_T], "Future[_T]"]:
|
|
15
|
+
"""
|
|
16
|
+
Wait for a future, shielding it from cancellation.
|
|
17
|
+
|
|
18
|
+
The statement
|
|
19
|
+
|
|
20
|
+
res = await shield(something())
|
|
21
|
+
|
|
22
|
+
is exactly equivalent to the statement
|
|
23
|
+
|
|
24
|
+
res = await something()
|
|
25
|
+
|
|
26
|
+
*except* that if the coroutine containing it is cancelled, the
|
|
27
|
+
task running in something() is not cancelled. From the POV of
|
|
28
|
+
something(), the cancellation did not happen. But its caller is
|
|
29
|
+
still cancelled, so the yield-from expression still raises
|
|
30
|
+
CancelledError. Note: If something() is cancelled by other means
|
|
31
|
+
this will still cancel shield().
|
|
32
|
+
|
|
33
|
+
If you want to completely ignore cancellation (not recommended)
|
|
34
|
+
you can combine shield() with a try/except clause, as follows:
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
res = await shield(something())
|
|
38
|
+
except CancelledError:
|
|
39
|
+
res = None
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
arg: The awaitable to shield from cancellation.
|
|
43
|
+
loop: Optional; the event loop. Deprecated since Python 3.8.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
A :class:`SmartFuture` or :class:`asyncio.Future` instance.
|
|
47
|
+
|
|
48
|
+
Example:
|
|
49
|
+
Using shield to protect a coroutine from cancellation:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
result = await shield(my_coroutine())
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
See Also:
|
|
56
|
+
- :func:`asyncio.shield`
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
class _SmartFutureMixin(Generic[_T]):
|
|
60
|
+
"""
|
|
61
|
+
Mixin class that provides common functionality for smart futures and tasks.
|
|
62
|
+
|
|
63
|
+
This mixin provides methods for managing waiters and integrating with a smart processing queue.
|
|
64
|
+
It uses weak references to manage resources efficiently.
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
Creating a SmartFuture and awaiting it:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
future = SmartFuture()
|
|
71
|
+
result = await future
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Creating a SmartTask and awaiting it:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
task = SmartTask(coro=my_coroutine())
|
|
78
|
+
result = await task
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
See Also:
|
|
82
|
+
- :class:`SmartFuture`
|
|
83
|
+
- :class:`SmartTask`
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
_queue: Optional["SmartProcessingQueue[Any, Any, _T]"] = None
|
|
87
|
+
_key: _Key
|
|
88
|
+
_waiters: "WeakSet[SmartTask[_T]]"
|
|
89
|
+
|
|
90
|
+
class SmartFuture(_SmartFutureMixin[_T], Future):
|
|
91
|
+
"""
|
|
92
|
+
A smart future that tracks waiters and integrates with a smart processing queue.
|
|
93
|
+
|
|
94
|
+
Inherits from both :class:`_SmartFutureMixin` and :class:`asyncio.Future`, providing additional functionality
|
|
95
|
+
for tracking waiters and integrating with a smart processing queue.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
Creating and awaiting a SmartFuture:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
future = SmartFuture()
|
|
102
|
+
await future
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
See Also:
|
|
106
|
+
- :class:`_SmartFutureMixin`
|
|
107
|
+
- :class:`asyncio.Future`
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
def __await__(self) -> Generator[Any, None, T]:
|
|
111
|
+
"""
|
|
112
|
+
Await the SmartFuture, handling waiters and logging.
|
|
113
|
+
|
|
114
|
+
Yields:
|
|
115
|
+
The result of the future.
|
|
116
|
+
|
|
117
|
+
Example:
|
|
118
|
+
```python
|
|
119
|
+
future = SmartFuture()
|
|
120
|
+
result = await future
|
|
121
|
+
```
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
def create_future(
|
|
125
|
+
*,
|
|
126
|
+
queue: Optional["SmartProcessingQueue"] = None,
|
|
127
|
+
key: Optional[_Key] = None,
|
|
128
|
+
loop: Optional[AbstractEventLoop] = None,
|
|
129
|
+
) -> SmartFuture[_T]:
|
|
130
|
+
"""
|
|
131
|
+
Create a :class:`~SmartFuture` instance.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
queue: Optional; a smart processing queue.
|
|
135
|
+
key: Optional; a key identifying the future.
|
|
136
|
+
loop: Optional; the event loop.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
A SmartFuture instance.
|
|
140
|
+
|
|
141
|
+
Example:
|
|
142
|
+
Creating a SmartFuture using the factory function:
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
future = create_future(queue=my_queue, key=my_key)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
See Also:
|
|
149
|
+
- :class:`SmartFuture`
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
class SmartTask(_SmartFutureMixin[_T], Task):
|
|
153
|
+
"""
|
|
154
|
+
A smart task that tracks waiters and integrates with a smart processing queue.
|
|
155
|
+
|
|
156
|
+
Inherits from both :class:`_SmartFutureMixin` and :class:`asyncio.Task`, providing additional functionality
|
|
157
|
+
for tracking waiters and integrating with a smart processing queue.
|
|
158
|
+
|
|
159
|
+
Example:
|
|
160
|
+
Creating and awaiting a SmartTask:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
task = SmartTask(coro=my_coroutine())
|
|
164
|
+
await task
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
See Also:
|
|
168
|
+
- :class:`_SmartFutureMixin`
|
|
169
|
+
- :class:`asyncio.Task`
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
def __await__(self) -> Generator[Any, None, T]:
|
|
173
|
+
"""
|
|
174
|
+
Await the SmartTask, handling waiters and logging.
|
|
175
|
+
|
|
176
|
+
Yields:
|
|
177
|
+
The result of the task.
|
|
178
|
+
|
|
179
|
+
Example:
|
|
180
|
+
```python
|
|
181
|
+
task = SmartTask(coro=my_coroutine())
|
|
182
|
+
result = await task
|
|
183
|
+
```
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
def set_smart_task_factory(loop: AbstractEventLoop = None) -> None:
|
|
187
|
+
"""
|
|
188
|
+
Set the event loop's task factory to :func:`~smart_task_factory` so all tasks will be SmartTask instances.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
loop: Optional; the event loop. If None, the current event loop is used.
|
|
192
|
+
|
|
193
|
+
Example:
|
|
194
|
+
Setting the smart task factory for the current event loop:
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
set_smart_task_factory()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
See Also:
|
|
201
|
+
- :func:`smart_task_factory`
|
|
202
|
+
"""
|