ez-a-sync 0.32.29__cp310-cp310-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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-win32.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/exceptions.pyi
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module defines custom exceptions for the a_sync library.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from asyncio import Task
|
|
6
|
+
from typing import Any, Optional, Type
|
|
7
|
+
|
|
8
|
+
class ASyncFlagException(ValueError):
|
|
9
|
+
"""
|
|
10
|
+
Base exception class for flag-related errors in the a_sync library.
|
|
11
|
+
|
|
12
|
+
A-Sync uses 'flags' to indicate whether objects or function calls will be sync or async.
|
|
13
|
+
You can use any of the provided flags, which include 'sync' and 'asynchronous', whichever makes most sense for your use case.
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
>>> try:
|
|
17
|
+
... raise ASyncFlagException("An error occurred with flags.")
|
|
18
|
+
... except ASyncFlagException as e:
|
|
19
|
+
... print(e)
|
|
20
|
+
An error occurred with flags.
|
|
21
|
+
|
|
22
|
+
See Also:
|
|
23
|
+
- :const:`VIABLE_FLAGS`
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
viable_flags: set[str]
|
|
27
|
+
"""The set of viable flags: {'sync', 'asynchronous'}."""
|
|
28
|
+
def desc(self, target) -> str:
|
|
29
|
+
"""
|
|
30
|
+
Returns a description of the target for the flag error message.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
target: The target object or string to describe.
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
>>> exception = ASyncFlagException()
|
|
37
|
+
>>> exception.desc("kwargs")
|
|
38
|
+
"flags present in 'kwargs'"
|
|
39
|
+
|
|
40
|
+
>>> exception.desc("some_target")
|
|
41
|
+
'flag attributes defined on some_target'
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
class NoFlagsFound(ASyncFlagException):
|
|
45
|
+
"""
|
|
46
|
+
Raised when no viable flags are found in the target.
|
|
47
|
+
|
|
48
|
+
Examples:
|
|
49
|
+
>>> try:
|
|
50
|
+
... raise NoFlagsFound("some_target")
|
|
51
|
+
... except NoFlagsFound as e:
|
|
52
|
+
... print(e)
|
|
53
|
+
There are no viable a_sync flag attributes defined on some_target:
|
|
54
|
+
Viable flags: {'sync', 'asynchronous'}
|
|
55
|
+
This is likely an issue with a custom subclass definition.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
def __init__(self, target, kwargs_keys=None) -> None:
|
|
59
|
+
"""
|
|
60
|
+
Initializes the NoFlagsFound exception.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
target: The target object where flags were expected.
|
|
64
|
+
kwargs_keys: Optional; keys in the kwargs if applicable.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
class TooManyFlags(ASyncFlagException):
|
|
68
|
+
"""
|
|
69
|
+
Raised when multiple flags are found, but only one was expected.
|
|
70
|
+
|
|
71
|
+
Examples:
|
|
72
|
+
>>> try:
|
|
73
|
+
... raise TooManyFlags("some_target", ["flag1", "flag2"])
|
|
74
|
+
... except TooManyFlags as e:
|
|
75
|
+
... print(e)
|
|
76
|
+
There are multiple a_sync flag attributes defined on some_target and there should only be one.
|
|
77
|
+
Present flags: ['flag1', 'flag2']
|
|
78
|
+
This is likely an issue with a custom subclass definition.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
def __init__(self, target, present_flags) -> None:
|
|
82
|
+
"""
|
|
83
|
+
Initializes the TooManyFlags exception.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
target: The target object where flags were found.
|
|
87
|
+
present_flags: The flags that were found.
|
|
88
|
+
|
|
89
|
+
See Also:
|
|
90
|
+
- :class:`ASyncFlagException`
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
class InvalidFlag(ASyncFlagException):
|
|
94
|
+
"""
|
|
95
|
+
Raised when an invalid flag is encountered.
|
|
96
|
+
|
|
97
|
+
Examples:
|
|
98
|
+
>>> try:
|
|
99
|
+
... raise InvalidFlag("invalid_flag")
|
|
100
|
+
... except InvalidFlag as e:
|
|
101
|
+
... print(e)
|
|
102
|
+
'flag' must be one of: {'sync', 'asynchronous'}. You passed invalid_flag.
|
|
103
|
+
This code should not be reached and likely indicates an issue with a custom subclass definition.
|
|
104
|
+
|
|
105
|
+
See Also:
|
|
106
|
+
- :const:`VIABLE_FLAGS`
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
def __init__(self, flag: Optional[str]) -> None:
|
|
110
|
+
"""
|
|
111
|
+
Initializes the InvalidFlag exception.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
flag: The invalid flag.
|
|
115
|
+
|
|
116
|
+
See Also:
|
|
117
|
+
- :class:`ASyncFlagException`
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
class InvalidFlagValue(ASyncFlagException):
|
|
121
|
+
"""
|
|
122
|
+
Raised when a flag has an invalid value.
|
|
123
|
+
|
|
124
|
+
Examples:
|
|
125
|
+
>>> try:
|
|
126
|
+
... raise InvalidFlagValue("some_flag", "not_a_boolean")
|
|
127
|
+
... except InvalidFlagValue as e:
|
|
128
|
+
... print(e)
|
|
129
|
+
'some_flag' should be boolean. You passed not_a_boolean.
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
def __init__(self, flag: str, flag_value: Any) -> None:
|
|
133
|
+
"""
|
|
134
|
+
Initializes the InvalidFlagValue exception.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
flag: The flag with an invalid value.
|
|
138
|
+
flag_value: The invalid value of the flag.
|
|
139
|
+
|
|
140
|
+
See Also:
|
|
141
|
+
- :class:`ASyncFlagException`
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
class FlagNotDefined(ASyncFlagException):
|
|
145
|
+
"""
|
|
146
|
+
Raised when a flag is not defined on an object.
|
|
147
|
+
|
|
148
|
+
Examples:
|
|
149
|
+
>>> class SomeClass:
|
|
150
|
+
... pass
|
|
151
|
+
...
|
|
152
|
+
>>> try:
|
|
153
|
+
... raise FlagNotDefined(SomeClass, "some_flag")
|
|
154
|
+
... except FlagNotDefined as e:
|
|
155
|
+
... print(e)
|
|
156
|
+
<class '__main__.SomeClass'> flag some_flag is not defined.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
def __init__(self, obj: Type, flag: str) -> None:
|
|
160
|
+
"""
|
|
161
|
+
Initializes the FlagNotDefined exception.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
obj: The object where the flag is not defined.
|
|
165
|
+
flag: The undefined flag.
|
|
166
|
+
|
|
167
|
+
See Also:
|
|
168
|
+
- :class:`ASyncFlagException`
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
class ImproperFunctionType(ValueError):
|
|
172
|
+
"""
|
|
173
|
+
Raised when a function that should be sync is async or vice-versa.
|
|
174
|
+
|
|
175
|
+
See Also:
|
|
176
|
+
- :class:`FunctionNotAsync`
|
|
177
|
+
- :class:`FunctionNotSync`
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
class FunctionNotAsync(ImproperFunctionType):
|
|
181
|
+
"""
|
|
182
|
+
Raised when a function expected to be async is not.
|
|
183
|
+
|
|
184
|
+
Examples:
|
|
185
|
+
>>> def some_function():
|
|
186
|
+
... pass
|
|
187
|
+
...
|
|
188
|
+
>>> try:
|
|
189
|
+
... raise FunctionNotAsync(some_function)
|
|
190
|
+
... except FunctionNotAsync as e:
|
|
191
|
+
... print(e)
|
|
192
|
+
`coro_fn` must be a coroutine function defined with `async def`. You passed <function some_function at 0x...>.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
def __init__(self, fn) -> None:
|
|
196
|
+
"""
|
|
197
|
+
Initializes the FunctionNotAsync exception.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
fn: The function that is not async.
|
|
201
|
+
|
|
202
|
+
See Also:
|
|
203
|
+
- :class:`ImproperFunctionType`
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
class FunctionNotSync(ImproperFunctionType):
|
|
207
|
+
"""
|
|
208
|
+
Raised when a function expected to be sync is actually async.
|
|
209
|
+
|
|
210
|
+
Examples:
|
|
211
|
+
>>> async def some_async_function():
|
|
212
|
+
... pass
|
|
213
|
+
...
|
|
214
|
+
>>> try:
|
|
215
|
+
... raise FunctionNotSync(some_async_function)
|
|
216
|
+
... except FunctionNotSync as e:
|
|
217
|
+
... print(e)
|
|
218
|
+
`func` must be a coroutine function defined with `def`. You passed <function some_async_function at 0x...>.
|
|
219
|
+
"""
|
|
220
|
+
|
|
221
|
+
def __init__(self, fn) -> None:
|
|
222
|
+
"""
|
|
223
|
+
Initializes the FunctionNotSync exception.
|
|
224
|
+
|
|
225
|
+
Args:
|
|
226
|
+
fn: The function that is not sync.
|
|
227
|
+
|
|
228
|
+
See Also:
|
|
229
|
+
- :class:`ImproperFunctionType`
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
class ASyncRuntimeError(RuntimeError):
|
|
233
|
+
"""
|
|
234
|
+
Raised for runtime errors in asynchronous operations.
|
|
235
|
+
|
|
236
|
+
Examples:
|
|
237
|
+
>>> try:
|
|
238
|
+
... raise ASyncRuntimeError(RuntimeError("Some runtime error"))
|
|
239
|
+
... except ASyncRuntimeError as e:
|
|
240
|
+
... print(e)
|
|
241
|
+
Some runtime error
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
def __init__(self, e: RuntimeError) -> None:
|
|
245
|
+
"""
|
|
246
|
+
Initializes the ASyncRuntimeError exception.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
e: The original runtime error.
|
|
250
|
+
|
|
251
|
+
See Also:
|
|
252
|
+
- :class:`RuntimeError`
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
class SyncModeInAsyncContextError(ASyncRuntimeError):
|
|
256
|
+
"""
|
|
257
|
+
Raised when synchronous code is used within an asynchronous context.
|
|
258
|
+
|
|
259
|
+
Examples:
|
|
260
|
+
>>> try:
|
|
261
|
+
... raise SyncModeInAsyncContextError()
|
|
262
|
+
... except SyncModeInAsyncContextError as e:
|
|
263
|
+
... print(e)
|
|
264
|
+
The event loop is already running, which means you're trying to use an `ASyncFunction` synchronously from within an async context.
|
|
265
|
+
Check your traceback to determine which, then try calling asynchronously instead with one of the following kwargs:
|
|
266
|
+
{'sync', 'asynchronous'}
|
|
267
|
+
"""
|
|
268
|
+
|
|
269
|
+
def __init__(self, err: str = "") -> None:
|
|
270
|
+
"""
|
|
271
|
+
Initializes the SyncModeInAsyncContextError exception.
|
|
272
|
+
|
|
273
|
+
See Also:
|
|
274
|
+
- :class:`ASyncRuntimeError`
|
|
275
|
+
"""
|
|
276
|
+
|
|
277
|
+
class MappingError(Exception):
|
|
278
|
+
"""
|
|
279
|
+
Base class for errors related to :class:`~TaskMapping`.
|
|
280
|
+
|
|
281
|
+
Examples:
|
|
282
|
+
>>> from a_sync import TaskMapping
|
|
283
|
+
>>> try:
|
|
284
|
+
... raise MappingError(TaskMapping(), "Some mapping error")
|
|
285
|
+
... except MappingError as e:
|
|
286
|
+
... print(e)
|
|
287
|
+
Some mapping error:
|
|
288
|
+
<TaskMapping object at 0x...>
|
|
289
|
+
{}
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
_msg: str
|
|
293
|
+
def __init__(self, mapping: "TaskMapping", msg: str = "") -> None:
|
|
294
|
+
"""
|
|
295
|
+
Initializes the MappingError exception.
|
|
296
|
+
|
|
297
|
+
Args:
|
|
298
|
+
mapping: The TaskMapping where the error occurred.
|
|
299
|
+
msg: An optional message describing the error.
|
|
300
|
+
|
|
301
|
+
See Also:
|
|
302
|
+
- :class:`TaskMapping`
|
|
303
|
+
"""
|
|
304
|
+
|
|
305
|
+
class MappingIsEmptyError(MappingError):
|
|
306
|
+
"""
|
|
307
|
+
Raised when a TaskMapping is empty and an operation requires it to have items.
|
|
308
|
+
|
|
309
|
+
Examples:
|
|
310
|
+
>>> from a_sync import TaskMapping
|
|
311
|
+
>>> try:
|
|
312
|
+
... raise MappingIsEmptyError(TaskMapping())
|
|
313
|
+
... except MappingIsEmptyError as e:
|
|
314
|
+
... print(e)
|
|
315
|
+
TaskMapping does not contain anything to yield:
|
|
316
|
+
<TaskMapping object at 0x...>
|
|
317
|
+
{}
|
|
318
|
+
"""
|
|
319
|
+
|
|
320
|
+
class MappingNotEmptyError(MappingError):
|
|
321
|
+
"""
|
|
322
|
+
Raised when a TaskMapping is not empty and an operation requires it to be empty.
|
|
323
|
+
|
|
324
|
+
Examples:
|
|
325
|
+
>>> from a_sync import TaskMapping
|
|
326
|
+
>>> task_mapping = TaskMapping()
|
|
327
|
+
>>> task_mapping['key'] = 'value'
|
|
328
|
+
>>> try:
|
|
329
|
+
... raise MappingNotEmptyError(task_mapping)
|
|
330
|
+
... except MappingNotEmptyError as e:
|
|
331
|
+
... print(e)
|
|
332
|
+
TaskMapping already contains some data. In order to use `map`, you need a fresh one:
|
|
333
|
+
<TaskMapping object at 0x...>
|
|
334
|
+
{'key': 'value'}
|
|
335
|
+
"""
|
|
336
|
+
|
|
337
|
+
class PersistedTaskException(Exception):
|
|
338
|
+
"""
|
|
339
|
+
Raised when an exception persists in an asyncio Task.
|
|
340
|
+
|
|
341
|
+
Examples:
|
|
342
|
+
>>> import asyncio
|
|
343
|
+
>>> async def some_task():
|
|
344
|
+
... raise ValueError("Some error")
|
|
345
|
+
...
|
|
346
|
+
>>> task = asyncio.create_task(some_task())
|
|
347
|
+
>>> try:
|
|
348
|
+
... raise PersistedTaskException(ValueError("Some error"), task)
|
|
349
|
+
... except PersistedTaskException as e:
|
|
350
|
+
... print(e)
|
|
351
|
+
ValueError: Some error
|
|
352
|
+
"""
|
|
353
|
+
|
|
354
|
+
def __init__(self, exc: Exception, task: Task) -> None:
|
|
355
|
+
"""
|
|
356
|
+
Initializes the PersistedTaskException exception.
|
|
357
|
+
|
|
358
|
+
Args:
|
|
359
|
+
exc: The exception that persisted.
|
|
360
|
+
task: The asyncio Task where the exception occurred.
|
|
361
|
+
|
|
362
|
+
See Also:
|
|
363
|
+
- :class:`asyncio.Task`
|
|
364
|
+
"""
|
|
365
|
+
|
|
366
|
+
class EmptySequenceError(ValueError):
|
|
367
|
+
"""
|
|
368
|
+
Raised when an operation is attempted on an empty sequence but items are required.
|
|
369
|
+
|
|
370
|
+
Examples:
|
|
371
|
+
>>> try:
|
|
372
|
+
... raise EmptySequenceError("Sequence is empty")
|
|
373
|
+
... except EmptySequenceError as e:
|
|
374
|
+
... print(e)
|
|
375
|
+
Sequence is empty
|
|
376
|
+
"""
|