ez-a-sync 0.22.14__py3-none-any.whl → 0.22.15__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.
Potentially problematic release.
This version of ez-a-sync might be problematic. Click here for more details.
- a_sync/ENVIRONMENT_VARIABLES.py +4 -3
- a_sync/__init__.py +30 -12
- a_sync/_smart.py +132 -28
- a_sync/_typing.py +56 -12
- a_sync/a_sync/__init__.py +35 -10
- a_sync/a_sync/_descriptor.py +74 -26
- a_sync/a_sync/_flags.py +14 -6
- a_sync/a_sync/_helpers.py +8 -7
- a_sync/a_sync/_kwargs.py +3 -2
- a_sync/a_sync/_meta.py +120 -28
- a_sync/a_sync/abstract.py +102 -28
- a_sync/a_sync/base.py +34 -16
- a_sync/a_sync/config.py +47 -13
- a_sync/a_sync/decorator.py +239 -117
- a_sync/a_sync/function.py +416 -146
- a_sync/a_sync/method.py +197 -59
- a_sync/a_sync/modifiers/__init__.py +47 -5
- a_sync/a_sync/modifiers/cache/__init__.py +46 -17
- a_sync/a_sync/modifiers/cache/memory.py +86 -20
- a_sync/a_sync/modifiers/limiter.py +52 -22
- a_sync/a_sync/modifiers/manager.py +98 -16
- a_sync/a_sync/modifiers/semaphores.py +48 -15
- a_sync/a_sync/property.py +383 -82
- a_sync/a_sync/singleton.py +1 -0
- a_sync/aliases.py +0 -1
- a_sync/asyncio/__init__.py +4 -1
- a_sync/asyncio/as_completed.py +177 -49
- a_sync/asyncio/create_task.py +31 -17
- a_sync/asyncio/gather.py +72 -52
- a_sync/asyncio/utils.py +3 -3
- a_sync/exceptions.py +78 -23
- a_sync/executor.py +118 -71
- a_sync/future.py +575 -158
- a_sync/iter.py +110 -50
- a_sync/primitives/__init__.py +14 -2
- a_sync/primitives/_debug.py +13 -13
- a_sync/primitives/_loggable.py +5 -4
- a_sync/primitives/locks/__init__.py +5 -2
- a_sync/primitives/locks/counter.py +38 -36
- a_sync/primitives/locks/event.py +21 -7
- a_sync/primitives/locks/prio_semaphore.py +182 -62
- a_sync/primitives/locks/semaphore.py +78 -77
- a_sync/primitives/queue.py +560 -58
- a_sync/sphinx/__init__.py +0 -1
- a_sync/sphinx/ext.py +160 -50
- a_sync/task.py +262 -97
- a_sync/utils/__init__.py +12 -6
- a_sync/utils/iterators.py +127 -43
- {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/METADATA +1 -1
- ez_a_sync-0.22.15.dist-info/RECORD +74 -0
- {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/WHEEL +1 -1
- tests/conftest.py +1 -2
- tests/executor.py +112 -9
- tests/fixtures.py +61 -32
- tests/test_abstract.py +7 -4
- tests/test_as_completed.py +54 -21
- tests/test_base.py +66 -17
- tests/test_cache.py +31 -15
- tests/test_decorator.py +54 -28
- tests/test_executor.py +8 -13
- tests/test_future.py +45 -8
- tests/test_gather.py +8 -2
- tests/test_helpers.py +2 -0
- tests/test_iter.py +55 -13
- tests/test_limiter.py +5 -3
- tests/test_meta.py +23 -9
- tests/test_modified.py +4 -1
- tests/test_semaphore.py +15 -8
- tests/test_singleton.py +15 -10
- tests/test_task.py +126 -28
- ez_a_sync-0.22.14.dist-info/RECORD +0 -74
- {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/LICENSE.txt +0 -0
- {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/top_level.txt +0 -0
a_sync/sphinx/__init__.py
CHANGED
a_sync/sphinx/ext.py
CHANGED
|
@@ -32,6 +32,7 @@ syntax.
|
|
|
32
32
|
|
|
33
33
|
Use ``.. autotask::`` to alternatively manually document a task.
|
|
34
34
|
"""
|
|
35
|
+
|
|
35
36
|
from inspect import signature
|
|
36
37
|
|
|
37
38
|
from docutils import nodes
|
|
@@ -39,151 +40,260 @@ from sphinx.domains.python import PyFunction, PyMethod
|
|
|
39
40
|
from sphinx.ext.autodoc import FunctionDocumenter, MethodDocumenter
|
|
40
41
|
|
|
41
42
|
from a_sync.a_sync._descriptor import ASyncDescriptor
|
|
42
|
-
from a_sync.a_sync.function import
|
|
43
|
+
from a_sync.a_sync.function import (
|
|
44
|
+
ASyncFunction,
|
|
45
|
+
ASyncFunctionAsyncDefault,
|
|
46
|
+
ASyncFunctionSyncDefault,
|
|
47
|
+
)
|
|
43
48
|
from a_sync.iter import ASyncGeneratorFunction
|
|
44
49
|
|
|
45
50
|
|
|
46
|
-
|
|
47
51
|
class _ASyncWrapperDocumenter:
|
|
52
|
+
"""Base class for documenters that handle wrapped ASync functions."""
|
|
53
|
+
|
|
48
54
|
typ: type
|
|
49
55
|
|
|
50
56
|
@classmethod
|
|
51
57
|
def can_document_member(cls, member, membername, isattr, parent):
|
|
52
|
-
|
|
58
|
+
"""Determine if the member can be documented by this documenter.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
member: The member to check.
|
|
62
|
+
membername: The name of the member.
|
|
63
|
+
isattr: Boolean indicating if the member is an attribute.
|
|
64
|
+
parent: The parent object.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
bool: True if the member can be documented, False otherwise.
|
|
68
|
+
"""
|
|
69
|
+
return (
|
|
70
|
+
isinstance(member, cls.typ) and getattr(member, "__wrapped__") is not None
|
|
71
|
+
)
|
|
53
72
|
|
|
54
73
|
def document_members(self, all_members=False):
|
|
74
|
+
"""Document members of the object.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
all_members: Boolean indicating if all members should be documented.
|
|
78
|
+
"""
|
|
55
79
|
pass
|
|
56
80
|
|
|
57
81
|
def check_module(self):
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
"""Check if the object is defined in the expected module.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
bool: True if the object is defined in the expected module, False otherwise.
|
|
86
|
+
|
|
87
|
+
Note:
|
|
88
|
+
Normally checks if *self.object* is really defined in the module
|
|
89
|
+
given by *self.modname*. But since functions decorated with the @task
|
|
90
|
+
decorator are instances living in the celery.local, we have to check
|
|
91
|
+
the wrapped function instead.
|
|
92
|
+
"""
|
|
93
|
+
wrapped = getattr(self.object, "__wrapped__", None)
|
|
94
|
+
if wrapped and getattr(wrapped, "__module__") == self.modname:
|
|
64
95
|
return True
|
|
65
96
|
return super().check_module()
|
|
66
97
|
|
|
98
|
+
|
|
67
99
|
class _ASyncFunctionDocumenter(_ASyncWrapperDocumenter, FunctionDocumenter):
|
|
100
|
+
"""Documenter for ASyncFunction instances."""
|
|
101
|
+
|
|
68
102
|
def format_args(self):
|
|
69
|
-
|
|
103
|
+
"""Format the arguments of the wrapped function.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
str: The formatted arguments.
|
|
107
|
+
"""
|
|
108
|
+
wrapped = getattr(self.object, "__wrapped__", None)
|
|
70
109
|
if wrapped is not None:
|
|
71
110
|
sig = signature(wrapped)
|
|
72
111
|
if "self" in sig.parameters or "cls" in sig.parameters:
|
|
73
112
|
sig = sig.replace(parameters=list(sig.parameters.values())[1:])
|
|
74
113
|
return str(sig)
|
|
75
|
-
return
|
|
114
|
+
return ""
|
|
115
|
+
|
|
76
116
|
|
|
77
117
|
class _ASyncMethodDocumenter(_ASyncWrapperDocumenter, MethodDocumenter):
|
|
118
|
+
"""Documenter for ASyncMethod instances."""
|
|
119
|
+
|
|
78
120
|
def format_args(self):
|
|
79
|
-
wrapped
|
|
121
|
+
"""Format the arguments of the wrapped method.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
str: The formatted arguments.
|
|
125
|
+
"""
|
|
126
|
+
wrapped = getattr(self.object, "__wrapped__")
|
|
80
127
|
if wrapped is not None:
|
|
81
128
|
return str(signature(wrapped))
|
|
82
|
-
return
|
|
83
|
-
|
|
129
|
+
return ""
|
|
130
|
+
|
|
131
|
+
|
|
84
132
|
class _ASyncDirective:
|
|
133
|
+
"""Base class for ASync directives."""
|
|
134
|
+
|
|
85
135
|
prefix_env: str
|
|
136
|
+
|
|
86
137
|
def get_signature_prefix(self, sig):
|
|
138
|
+
"""Get the signature prefix for the directive.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
sig: The signature to process.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
list: A list of nodes representing the signature prefix.
|
|
145
|
+
"""
|
|
87
146
|
return [nodes.Text(getattr(self.env.config, self.prefix_env))]
|
|
88
147
|
|
|
148
|
+
|
|
89
149
|
class _ASyncFunctionDirective(_ASyncDirective, PyFunction):
|
|
150
|
+
"""Directive for ASyncFunction instances."""
|
|
151
|
+
|
|
90
152
|
pass
|
|
91
153
|
|
|
154
|
+
|
|
92
155
|
class _ASyncMethodDirective(_ASyncDirective, PyMethod):
|
|
156
|
+
"""Directive for ASyncMethod instances."""
|
|
157
|
+
|
|
93
158
|
pass
|
|
94
|
-
|
|
159
|
+
|
|
95
160
|
|
|
96
161
|
class ASyncFunctionDocumenter(_ASyncFunctionDocumenter):
|
|
97
162
|
"""Document ASyncFunction instance definitions."""
|
|
98
|
-
|
|
163
|
+
|
|
164
|
+
objtype = "a_sync_function"
|
|
99
165
|
typ = ASyncFunction
|
|
100
166
|
priority = 15
|
|
101
|
-
#member_order = 11
|
|
167
|
+
# member_order = 11
|
|
168
|
+
|
|
102
169
|
|
|
103
170
|
class ASyncFunctionSyncDocumenter(_ASyncFunctionDocumenter):
|
|
104
|
-
"""Document
|
|
105
|
-
|
|
171
|
+
"""Document ASyncFunctionSyncDefault instance definitions."""
|
|
172
|
+
|
|
173
|
+
objtype = "a_sync_function_sync"
|
|
106
174
|
typ = ASyncFunctionSyncDefault
|
|
107
175
|
priority = 14
|
|
108
|
-
#member_order = 11
|
|
176
|
+
# member_order = 11
|
|
177
|
+
|
|
109
178
|
|
|
110
179
|
class ASyncFunctionAsyncDocumenter(_ASyncFunctionDocumenter):
|
|
111
|
-
"""Document
|
|
112
|
-
|
|
180
|
+
"""Document ASyncFunctionAsyncDefault instance definitions."""
|
|
181
|
+
|
|
182
|
+
objtype = "a_sync_function_async"
|
|
113
183
|
typ = ASyncFunctionAsyncDefault
|
|
114
184
|
priority = 13
|
|
115
|
-
#member_order = 11
|
|
185
|
+
# member_order = 11
|
|
116
186
|
|
|
117
187
|
|
|
118
188
|
class ASyncFunctionDirective(_ASyncFunctionDirective):
|
|
189
|
+
"""Directive for ASyncFunction instances."""
|
|
190
|
+
|
|
119
191
|
prefix_env = "a_sync_function_prefix"
|
|
120
192
|
|
|
193
|
+
|
|
121
194
|
class ASyncFunctionSyncDirective(_ASyncFunctionDirective):
|
|
195
|
+
"""Directive for ASyncFunctionSyncDefault instances."""
|
|
196
|
+
|
|
122
197
|
prefix_env = "a_sync_function_sync_prefix"
|
|
123
198
|
|
|
199
|
+
|
|
124
200
|
class ASyncFunctionAsyncDirective(_ASyncFunctionDirective):
|
|
201
|
+
"""Directive for ASyncFunctionAsyncDefault instances."""
|
|
202
|
+
|
|
125
203
|
prefix_env = "a_sync_function_async_prefix"
|
|
126
204
|
|
|
127
205
|
|
|
128
206
|
class ASyncDescriptorDocumenter(_ASyncMethodDocumenter):
|
|
129
207
|
"""Document ASyncDescriptor instance definitions."""
|
|
130
|
-
|
|
208
|
+
|
|
209
|
+
objtype = "a_sync_descriptor"
|
|
131
210
|
typ = ASyncDescriptor
|
|
132
|
-
#member_order = 11
|
|
211
|
+
# member_order = 11
|
|
133
212
|
|
|
134
213
|
|
|
135
214
|
class ASyncDescriptorDirective(_ASyncMethodDirective):
|
|
136
|
-
"""
|
|
215
|
+
"""Directive for ASyncDescriptor instances."""
|
|
216
|
+
|
|
137
217
|
prefix_env = "a_sync_descriptor_prefix"
|
|
138
218
|
|
|
139
219
|
|
|
140
220
|
class ASyncGeneratorFunctionDocumenter(_ASyncFunctionDocumenter):
|
|
141
|
-
"""Document
|
|
142
|
-
|
|
221
|
+
"""Document ASyncGeneratorFunction instance definitions."""
|
|
222
|
+
|
|
223
|
+
objtype = "a_sync_generator_function"
|
|
143
224
|
typ = ASyncGeneratorFunction
|
|
144
|
-
#member_order = 11
|
|
225
|
+
# member_order = 11
|
|
145
226
|
|
|
146
227
|
|
|
147
228
|
class ASyncGeneratorFunctionDirective(_ASyncFunctionDirective):
|
|
148
|
-
"""
|
|
229
|
+
"""Directive for ASyncGeneratorFunction instances."""
|
|
230
|
+
|
|
149
231
|
prefix_env = "a_sync_generator_function_prefix"
|
|
150
232
|
|
|
233
|
+
|
|
151
234
|
def autodoc_skip_member_handler(app, what, name, obj, skip, options):
|
|
152
|
-
"""Handler for autodoc-skip-member event.
|
|
153
|
-
|
|
235
|
+
"""Handler for autodoc-skip-member event.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
app: The Sphinx application object.
|
|
239
|
+
what: The type of the object being documented.
|
|
240
|
+
name: The name of the object.
|
|
241
|
+
obj: The object itself.
|
|
242
|
+
skip: Boolean indicating if the member should be skipped.
|
|
243
|
+
options: The options for the autodoc directive.
|
|
244
|
+
|
|
245
|
+
Returns:
|
|
246
|
+
bool: True if the member should be skipped, False otherwise.
|
|
247
|
+
"""
|
|
248
|
+
if isinstance(
|
|
249
|
+
obj, (ASyncFunction, ASyncDescriptor, ASyncGeneratorFunction)
|
|
250
|
+
) and getattr(obj, "__wrapped__"):
|
|
154
251
|
if skip:
|
|
155
252
|
return False
|
|
156
253
|
return None
|
|
157
254
|
|
|
158
255
|
|
|
159
256
|
def setup(app):
|
|
160
|
-
"""Setup Sphinx extension.
|
|
161
|
-
|
|
162
|
-
|
|
257
|
+
"""Setup Sphinx extension.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
app: The Sphinx application object.
|
|
261
|
+
|
|
262
|
+
Returns:
|
|
263
|
+
dict: A dictionary with metadata about the extension.
|
|
264
|
+
"""
|
|
265
|
+
app.setup_extension("sphinx.ext.autodoc")
|
|
266
|
+
|
|
163
267
|
# function
|
|
164
268
|
app.add_autodocumenter(ASyncFunctionDocumenter)
|
|
165
269
|
app.add_autodocumenter(ASyncFunctionSyncDocumenter)
|
|
166
270
|
app.add_autodocumenter(ASyncFunctionAsyncDocumenter)
|
|
167
|
-
app.add_directive_to_domain(
|
|
168
|
-
app.add_directive_to_domain(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
app.
|
|
172
|
-
|
|
271
|
+
app.add_directive_to_domain("py", "a_sync_function", ASyncFunctionDirective)
|
|
272
|
+
app.add_directive_to_domain(
|
|
273
|
+
"py", "a_sync_function_sync", ASyncFunctionSyncDirective
|
|
274
|
+
)
|
|
275
|
+
app.add_directive_to_domain(
|
|
276
|
+
"py", "a_sync_function_async", ASyncFunctionAsyncDirective
|
|
277
|
+
)
|
|
278
|
+
app.add_config_value("a_sync_function_sync_prefix", "ASyncFunction (sync)", True)
|
|
279
|
+
app.add_config_value("a_sync_function_async_prefix", "ASyncFunction (async)", True)
|
|
280
|
+
app.add_config_value("a_sync_function_prefix", "ASyncFunction", True)
|
|
173
281
|
|
|
174
282
|
# descriptor
|
|
175
283
|
app.add_autodocumenter(ASyncDescriptorDocumenter)
|
|
176
|
-
app.add_directive_to_domain(
|
|
177
|
-
app.add_config_value(
|
|
284
|
+
app.add_directive_to_domain("py", "a_sync_descriptor", ASyncDescriptorDirective)
|
|
285
|
+
app.add_config_value("a_sync_descriptor_prefix", "ASyncDescriptor", True)
|
|
178
286
|
|
|
179
287
|
# generator
|
|
180
|
-
|
|
288
|
+
|
|
181
289
|
app.add_autodocumenter(ASyncGeneratorFunctionDocumenter)
|
|
182
|
-
app.add_directive_to_domain(
|
|
183
|
-
|
|
290
|
+
app.add_directive_to_domain(
|
|
291
|
+
"py", "a_sync_generator_function", ASyncGeneratorFunctionDirective
|
|
292
|
+
)
|
|
293
|
+
app.add_config_value(
|
|
294
|
+
"a_sync_generator_function_prefix", "ASyncGeneratorFunction", True
|
|
295
|
+
)
|
|
184
296
|
|
|
185
|
-
app.connect(
|
|
297
|
+
app.connect("autodoc-skip-member", autodoc_skip_member_handler)
|
|
186
298
|
|
|
187
|
-
return {
|
|
188
|
-
'parallel_read_safe': True
|
|
189
|
-
}
|
|
299
|
+
return {"parallel_read_safe": True}
|