ez-a-sync 0.32.16__cp311-cp311-macosx_11_0_arm64.whl → 0.32.17__cp311-cp311-macosx_11_0_arm64.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/_smart.cpython-311-darwin.so +0 -0
- a_sync/a_sync/_descriptor.c +4 -0
- a_sync/a_sync/_descriptor.cpython-311-darwin.so +0 -0
- a_sync/a_sync/_flags.cpython-311-darwin.so +0 -0
- a_sync/a_sync/_helpers.c +4 -0
- a_sync/a_sync/_helpers.cpython-311-darwin.so +0 -0
- a_sync/a_sync/_kwargs.cpython-311-darwin.so +0 -0
- a_sync/a_sync/_meta.py +2 -2
- a_sync/a_sync/abstract.cpython-311-darwin.so +0 -0
- a_sync/a_sync/base.cpython-311-darwin.so +0 -0
- a_sync/a_sync/flags.cpython-311-darwin.so +0 -0
- a_sync/a_sync/function.c +3633 -3272
- a_sync/a_sync/function.cpython-311-darwin.so +0 -0
- a_sync/a_sync/function.pxd +5 -1
- a_sync/a_sync/function.pyx +82 -79
- a_sync/a_sync/method.c +9838 -7638
- a_sync/a_sync/method.cpython-311-darwin.so +0 -0
- a_sync/a_sync/method.pxd +8 -1
- a_sync/a_sync/method.pyx +108 -84
- a_sync/a_sync/modifiers/manager.cpython-311-darwin.so +0 -0
- a_sync/a_sync/property.c +435 -384
- a_sync/a_sync/property.cpython-311-darwin.so +0 -0
- a_sync/a_sync/property.pyx +9 -7
- a_sync/async_property/cached.cpython-311-darwin.so +0 -0
- a_sync/async_property/proxy.cpython-311-darwin.so +0 -0
- a_sync/asyncio/as_completed.cpython-311-darwin.so +0 -0
- a_sync/asyncio/create_task.cpython-311-darwin.so +0 -0
- a_sync/asyncio/gather.cpython-311-darwin.so +0 -0
- a_sync/asyncio/igather.cpython-311-darwin.so +0 -0
- a_sync/asyncio/sleep.cpython-311-darwin.so +0 -0
- a_sync/debugging.cpython-311-darwin.so +0 -0
- a_sync/exceptions.cpython-311-darwin.so +0 -0
- a_sync/functools.cpython-311-darwin.so +0 -0
- a_sync/iter.cpython-311-darwin.so +0 -0
- a_sync/primitives/_debug.cpython-311-darwin.so +0 -0
- a_sync/primitives/_loggable.cpython-311-darwin.so +0 -0
- a_sync/primitives/locks/counter.cpython-311-darwin.so +0 -0
- a_sync/primitives/locks/event.cpython-311-darwin.so +0 -0
- a_sync/primitives/locks/prio_semaphore.cpython-311-darwin.so +0 -0
- a_sync/primitives/locks/semaphore.cpython-311-darwin.so +0 -0
- a_sync/task.py +1 -1
- a_sync/utils/repr.cpython-311-darwin.so +0 -0
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.17.dist-info}/METADATA +1 -1
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.17.dist-info}/RECORD +47 -47
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.17.dist-info}/WHEEL +0 -0
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.17.dist-info}/licenses/LICENSE.txt +0 -0
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.17.dist-info}/top_level.txt +0 -0
|
Binary file
|
a_sync/a_sync/function.pxd
CHANGED
|
@@ -20,5 +20,9 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
20
20
|
cdef object __modified_fn
|
|
21
21
|
cdef object __async_wrap
|
|
22
22
|
cdef object __sync_wrap
|
|
23
|
+
cdef object get_fn(self)
|
|
24
|
+
cpdef bint is_async_def(self)
|
|
25
|
+
cpdef bint is_sync_default(self)
|
|
26
|
+
cdef inline bint _run_sync(self, dict kwargs)
|
|
23
27
|
|
|
24
|
-
cdef void _validate_wrapped_fn(object fn)
|
|
28
|
+
cdef void _validate_wrapped_fn(object fn)
|
a_sync/a_sync/function.pyx
CHANGED
|
@@ -203,29 +203,6 @@ cdef inline void _validate_argspec(fn: Callable):
|
|
|
203
203
|
f"{fn} must not have any arguments with the following names: {VIABLE_FLAGS}"
|
|
204
204
|
)
|
|
205
205
|
|
|
206
|
-
cdef inline bint _run_sync(object function, dict kwargs):
|
|
207
|
-
"""
|
|
208
|
-
Determines whether to run the function synchronously or asynchronously.
|
|
209
|
-
|
|
210
|
-
This method checks for a flag in the kwargs and defers to it if present.
|
|
211
|
-
If no flag is specified, it defers to the default execution mode.
|
|
212
|
-
|
|
213
|
-
Args:
|
|
214
|
-
kwargs: The keyword arguments passed to the function.
|
|
215
|
-
|
|
216
|
-
Returns:
|
|
217
|
-
True if the function should run synchronously, otherwise False.
|
|
218
|
-
|
|
219
|
-
See Also:
|
|
220
|
-
- :func:`_kwargs.get_flag_name`
|
|
221
|
-
"""
|
|
222
|
-
cdef str flag = get_flag_name(kwargs)
|
|
223
|
-
if flag:
|
|
224
|
-
# If a flag was specified in the kwargs, we will defer to it.
|
|
225
|
-
return is_sync(flag, kwargs, pop_flag=True)
|
|
226
|
-
else:
|
|
227
|
-
# No flag specified in the kwargs, we will defer to 'default'.
|
|
228
|
-
return function._sync_default
|
|
229
206
|
|
|
230
207
|
cdef class _ASyncFunction(_ModifiedMixin):
|
|
231
208
|
"""
|
|
@@ -317,10 +294,11 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
317
294
|
- :attr:`default`
|
|
318
295
|
- :meth:`_run_sync`
|
|
319
296
|
"""
|
|
297
|
+
fn = self.get_fn()
|
|
320
298
|
_logger_debug(
|
|
321
|
-
"calling %s fn: %s with args: %s kwargs: %s", self,
|
|
299
|
+
"calling %s fn: %s with args: %s kwargs: %s", self, fn, args, kwargs
|
|
322
300
|
)
|
|
323
|
-
return
|
|
301
|
+
return fn(*args, **kwargs)
|
|
324
302
|
|
|
325
303
|
def __repr__(self) -> str:
|
|
326
304
|
return "<{} {}.{} at {}>".format(
|
|
@@ -341,9 +319,12 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
341
319
|
- :meth:`_async_wrap`
|
|
342
320
|
- :meth:`_sync_wrap`
|
|
343
321
|
"""
|
|
322
|
+
return self.get_fn()
|
|
323
|
+
|
|
324
|
+
cdef object get_fn(self):
|
|
344
325
|
fn = self._fn
|
|
345
326
|
if fn is None:
|
|
346
|
-
fn = self._async_wrap if self.
|
|
327
|
+
fn = self._async_wrap if self.is_async_def() else self._sync_wrap
|
|
347
328
|
self._fn = fn
|
|
348
329
|
return fn
|
|
349
330
|
|
|
@@ -707,51 +688,6 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
707
688
|
**function_kwargs,
|
|
708
689
|
).sum(pop=True, sync=False)
|
|
709
690
|
|
|
710
|
-
@property
|
|
711
|
-
def _sync_default(self) -> bint:
|
|
712
|
-
"""
|
|
713
|
-
Determines the default execution mode (sync or async) for the function.
|
|
714
|
-
|
|
715
|
-
If the user did not specify a default, this method defers to the function's
|
|
716
|
-
definition (sync vs async def).
|
|
717
|
-
|
|
718
|
-
Returns:
|
|
719
|
-
True if the default is sync, False if async.
|
|
720
|
-
|
|
721
|
-
See Also:
|
|
722
|
-
- :attr:`default`
|
|
723
|
-
"""
|
|
724
|
-
if self.__sync_default_cached:
|
|
725
|
-
return self.__sync_default
|
|
726
|
-
|
|
727
|
-
cdef str default = self.get_default()
|
|
728
|
-
cdef bint sync_default = (
|
|
729
|
-
True
|
|
730
|
-
if default == "sync"
|
|
731
|
-
else False if default == "async" else not self._async_def
|
|
732
|
-
)
|
|
733
|
-
self.__sync_default = sync_default
|
|
734
|
-
self.__sync_default_cached = True
|
|
735
|
-
return sync_default
|
|
736
|
-
|
|
737
|
-
@property
|
|
738
|
-
def _async_def(self) -> bint:
|
|
739
|
-
"""
|
|
740
|
-
Checks if the wrapped function is an asynchronous function.
|
|
741
|
-
|
|
742
|
-
Returns:
|
|
743
|
-
True if the function is asynchronous, otherwise False.
|
|
744
|
-
|
|
745
|
-
See Also:
|
|
746
|
-
- :func:`asyncio.iscoroutinefunction`
|
|
747
|
-
"""
|
|
748
|
-
if self.__async_def_cached:
|
|
749
|
-
return self.__async_def
|
|
750
|
-
cdef bint async_def
|
|
751
|
-
async_def = self.__async_def = iscoroutinefunction(self.__wrapped__)
|
|
752
|
-
self.__async_def_cached = True
|
|
753
|
-
return async_def
|
|
754
|
-
|
|
755
691
|
@property
|
|
756
692
|
def _asyncified(self) -> CoroFn[P, T]:
|
|
757
693
|
"""
|
|
@@ -768,7 +704,7 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
768
704
|
"""
|
|
769
705
|
asyncified = self.__asyncified
|
|
770
706
|
if asyncified is None:
|
|
771
|
-
if self.
|
|
707
|
+
if self.is_async_def():
|
|
772
708
|
raise TypeError(
|
|
773
709
|
f"Can only be applied to sync functions, not {self.__wrapped__}"
|
|
774
710
|
)
|
|
@@ -793,7 +729,7 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
793
729
|
"""
|
|
794
730
|
modified_fn = self.__modified_fn
|
|
795
731
|
if modified_fn is None:
|
|
796
|
-
if self.
|
|
732
|
+
if self.is_async_def():
|
|
797
733
|
modified_fn = self.__modified_fn = self.modifiers.apply_async_modifiers(self.__wrapped__)
|
|
798
734
|
else:
|
|
799
735
|
modified_fn = self.__modified_fn = self.modifiers.apply_sync_modifiers(self.__wrapped__)
|
|
@@ -825,7 +761,7 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
825
761
|
# we dont want this so profiler outputs are more useful
|
|
826
762
|
|
|
827
763
|
# Must take place before coro is created, we're popping a kwarg.
|
|
828
|
-
should_await = _run_sync(
|
|
764
|
+
should_await = self._run_sync(kwargs)
|
|
829
765
|
coro = modified_fn(*args, **kwargs)
|
|
830
766
|
if should_await:
|
|
831
767
|
return await_helper(coro)
|
|
@@ -858,7 +794,7 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
858
794
|
|
|
859
795
|
@wraps(modified_fn)
|
|
860
796
|
def sync_wrap(*args: P.args, **kwargs: P.kwargs) -> MaybeAwaitable[T]: # type: ignore [name-defined]
|
|
861
|
-
if _run_sync(
|
|
797
|
+
if self._run_sync(kwargs):
|
|
862
798
|
return modified_fn(*args, **kwargs)
|
|
863
799
|
return asyncified(*args, **kwargs)
|
|
864
800
|
|
|
@@ -866,6 +802,73 @@ cdef class _ASyncFunction(_ModifiedMixin):
|
|
|
866
802
|
|
|
867
803
|
return sync_wrap
|
|
868
804
|
|
|
805
|
+
cpdef bint is_async_def(self):
|
|
806
|
+
"""
|
|
807
|
+
Checks if the wrapped function is an asynchronous function.
|
|
808
|
+
|
|
809
|
+
Returns:
|
|
810
|
+
True if the function is asynchronous, otherwise False.
|
|
811
|
+
|
|
812
|
+
See Also:
|
|
813
|
+
- :func:`asyncio.iscoroutinefunction`
|
|
814
|
+
"""
|
|
815
|
+
if self.__async_def_cached:
|
|
816
|
+
return self.__async_def
|
|
817
|
+
cdef bint async_def
|
|
818
|
+
async_def = self.__async_def = iscoroutinefunction(self.__wrapped__)
|
|
819
|
+
self.__async_def_cached = True
|
|
820
|
+
return async_def
|
|
821
|
+
|
|
822
|
+
cpdef bint is_sync_default(self):
|
|
823
|
+
"""
|
|
824
|
+
Determines the default execution mode (sync or async) for the function.
|
|
825
|
+
|
|
826
|
+
If the user did not specify a default, this method defers to the function's
|
|
827
|
+
definition (sync vs async def).
|
|
828
|
+
|
|
829
|
+
Returns:
|
|
830
|
+
True if the default is sync, False if async.
|
|
831
|
+
|
|
832
|
+
See Also:
|
|
833
|
+
- :attr:`default`
|
|
834
|
+
"""
|
|
835
|
+
if self.__sync_default_cached:
|
|
836
|
+
return self.__sync_default
|
|
837
|
+
|
|
838
|
+
cdef str default = self.get_default()
|
|
839
|
+
cdef bint sync_default = (
|
|
840
|
+
True
|
|
841
|
+
if default == "sync"
|
|
842
|
+
else False if default == "async" else not self.is_async_def()
|
|
843
|
+
)
|
|
844
|
+
self.__sync_default = sync_default
|
|
845
|
+
self.__sync_default_cached = True
|
|
846
|
+
return sync_default
|
|
847
|
+
|
|
848
|
+
cdef inline bint _run_sync(self, dict kwargs):
|
|
849
|
+
"""
|
|
850
|
+
Determines whether to run the function synchronously or asynchronously.
|
|
851
|
+
|
|
852
|
+
This method checks for a flag in the kwargs and defers to it if present.
|
|
853
|
+
If no flag is specified, it defers to the default execution mode.
|
|
854
|
+
|
|
855
|
+
Args:
|
|
856
|
+
kwargs: The keyword arguments passed to the function.
|
|
857
|
+
|
|
858
|
+
Returns:
|
|
859
|
+
True if the function should run synchronously, otherwise False.
|
|
860
|
+
|
|
861
|
+
See Also:
|
|
862
|
+
- :func:`_kwargs.get_flag_name`
|
|
863
|
+
"""
|
|
864
|
+
cdef str flag = get_flag_name(kwargs)
|
|
865
|
+
if flag:
|
|
866
|
+
# If a flag was specified in the kwargs, we will defer to it.
|
|
867
|
+
return is_sync(flag, kwargs, pop_flag=True)
|
|
868
|
+
else:
|
|
869
|
+
# No flag specified in the kwargs, we will defer to 'default'.
|
|
870
|
+
return self.is_sync_default()
|
|
871
|
+
|
|
869
872
|
|
|
870
873
|
class ASyncFunction(_ASyncFunction, Generic[P, T]):
|
|
871
874
|
|
|
@@ -1157,7 +1160,7 @@ class ASyncFunctionSyncDefault(ASyncFunction[P, T]):
|
|
|
1157
1160
|
# TODO write specific docs for this overload
|
|
1158
1161
|
...
|
|
1159
1162
|
|
|
1160
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]:
|
|
1163
|
+
def __call__(_ASyncFunction self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]:
|
|
1161
1164
|
"""Calls the wrapped function, defaulting to synchronous execution.
|
|
1162
1165
|
|
|
1163
1166
|
This method overrides the base :meth:`ASyncFunction.__call__` to provide a synchronous
|
|
@@ -1176,7 +1179,7 @@ class ASyncFunctionSyncDefault(ASyncFunction[P, T]):
|
|
|
1176
1179
|
See Also:
|
|
1177
1180
|
- :meth:`ASyncFunction.__call__`
|
|
1178
1181
|
"""
|
|
1179
|
-
return self.
|
|
1182
|
+
return self.get_fn()(*args, **kwargs)
|
|
1180
1183
|
|
|
1181
1184
|
__docstring_append__ = ":class:`~a_sync.a_sync.function.ASyncFunctionSyncDefault`, you can optionally pass `sync=False` or `asynchronous=True` to force it to return a coroutine. Without either kwarg, it will run synchronously."
|
|
1182
1185
|
|
|
@@ -1232,7 +1235,7 @@ class ASyncFunctionAsyncDefault(ASyncFunction[P, T]):
|
|
|
1232
1235
|
|
|
1233
1236
|
@overload
|
|
1234
1237
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T]: ...
|
|
1235
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]:
|
|
1238
|
+
def __call__(_ASyncFunction self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]:
|
|
1236
1239
|
"""Calls the wrapped function, defaulting to asynchronous execution.
|
|
1237
1240
|
|
|
1238
1241
|
This method overrides the base :meth:`ASyncFunction.__call__` to provide an asynchronous
|
|
@@ -1251,7 +1254,7 @@ class ASyncFunctionAsyncDefault(ASyncFunction[P, T]):
|
|
|
1251
1254
|
See Also:
|
|
1252
1255
|
- :meth:`ASyncFunction.__call__`
|
|
1253
1256
|
"""
|
|
1254
|
-
return self.
|
|
1257
|
+
return self.get_fn()(*args, **kwargs)
|
|
1255
1258
|
|
|
1256
1259
|
__docstring_append__ = ":class:`~a_sync.a_sync.function.ASyncFunctionAsyncDefault`, you can optionally pass `sync=True` or `asynchronous=False` to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await."
|
|
1257
1260
|
|