ez-a-sync 0.32.16__cp310-cp310-win32.whl → 0.32.18__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/_smart.cp310-win32.pyd +0 -0
- a_sync/a_sync/_descriptor.c +4 -0
- a_sync/a_sync/_descriptor.cp310-win32.pyd +0 -0
- a_sync/a_sync/_flags.cp310-win32.pyd +0 -0
- a_sync/a_sync/_helpers.c +4 -0
- a_sync/a_sync/_helpers.cp310-win32.pyd +0 -0
- a_sync/a_sync/_kwargs.cp310-win32.pyd +0 -0
- a_sync/a_sync/_meta.py +2 -2
- a_sync/a_sync/abstract.cp310-win32.pyd +0 -0
- a_sync/a_sync/base.cp310-win32.pyd +0 -0
- a_sync/a_sync/flags.cp310-win32.pyd +0 -0
- a_sync/a_sync/function.c +3494 -3054
- a_sync/a_sync/function.cp310-win32.pyd +0 -0
- a_sync/a_sync/function.pxd +5 -1
- a_sync/a_sync/function.pyx +97 -81
- a_sync/a_sync/method.c +9838 -7638
- a_sync/a_sync/method.cp310-win32.pyd +0 -0
- a_sync/a_sync/method.pxd +8 -1
- a_sync/a_sync/method.pyx +108 -84
- a_sync/a_sync/modifiers/manager.cp310-win32.pyd +0 -0
- a_sync/a_sync/property.c +435 -384
- a_sync/a_sync/property.cp310-win32.pyd +0 -0
- a_sync/a_sync/property.pyx +9 -7
- a_sync/async_property/cached.cp310-win32.pyd +0 -0
- a_sync/async_property/proxy.cp310-win32.pyd +0 -0
- a_sync/asyncio/as_completed.cp310-win32.pyd +0 -0
- a_sync/asyncio/create_task.cp310-win32.pyd +0 -0
- a_sync/asyncio/gather.cp310-win32.pyd +0 -0
- a_sync/asyncio/igather.cp310-win32.pyd +0 -0
- a_sync/asyncio/sleep.cp310-win32.pyd +0 -0
- a_sync/debugging.cp310-win32.pyd +0 -0
- a_sync/exceptions.cp310-win32.pyd +0 -0
- a_sync/functools.cp310-win32.pyd +0 -0
- a_sync/iter.cp310-win32.pyd +0 -0
- a_sync/primitives/_debug.cp310-win32.pyd +0 -0
- a_sync/primitives/_loggable.cp310-win32.pyd +0 -0
- a_sync/primitives/locks/counter.cp310-win32.pyd +0 -0
- a_sync/primitives/locks/event.cp310-win32.pyd +0 -0
- a_sync/primitives/locks/prio_semaphore.cp310-win32.pyd +0 -0
- a_sync/primitives/locks/semaphore.cp310-win32.pyd +0 -0
- a_sync/task.py +1 -1
- a_sync/utils/repr.cp310-win32.pyd +0 -0
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.18.dist-info}/METADATA +1 -1
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.18.dist-info}/RECORD +47 -47
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.18.dist-info}/WHEEL +0 -0
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.18.dist-info}/licenses/LICENSE.txt +0 -0
- {ez_a_sync-0.32.16.dist-info → ez_a_sync-0.32.18.dist-info}/top_level.txt +0 -0
|
Binary file
|
a_sync/a_sync/method.pxd
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
from a_sync.a_sync.function cimport _ASyncFunction
|
|
2
|
+
cdef class _ASyncBoundMethod(_ASyncFunction):
|
|
3
|
+
cdef readonly object __weakself__
|
|
4
|
+
cdef readonly bint _is_async_def
|
|
5
|
+
cdef readonly object _cache_handle
|
|
6
|
+
cdef object c_map(self, tuple iterables, object concurrency, str task_name, dict kwargs)
|
|
7
|
+
cdef object __c_self__(self)
|
|
1
8
|
cdef bint _is_a_sync_instance(object instance)
|
|
2
|
-
cdef void _update_cache_timer(str field_name, object instance,
|
|
9
|
+
cdef void _update_cache_timer(str field_name, object instance, _ASyncBoundMethod bound)
|
a_sync/a_sync/method.pyx
CHANGED
|
@@ -272,7 +272,7 @@ class ASyncMethodDescriptor(ASyncDescriptor[I, P, T]):
|
|
|
272
272
|
return self._is_async_def
|
|
273
273
|
|
|
274
274
|
|
|
275
|
-
cdef void _update_cache_timer(str field_name, instance
|
|
275
|
+
cdef void _update_cache_timer(str field_name, object instance, _ASyncBoundMethod bound):
|
|
276
276
|
"""
|
|
277
277
|
Update the TTL for the cache handle for the instance.
|
|
278
278
|
|
|
@@ -491,7 +491,7 @@ cdef bint _is_a_sync_instance(object instance):
|
|
|
491
491
|
return is_a_sync
|
|
492
492
|
|
|
493
493
|
|
|
494
|
-
cdef bint _should_await(
|
|
494
|
+
cdef bint _should_await(_ASyncBoundMethod self, dict kwargs):
|
|
495
495
|
"""
|
|
496
496
|
Determine if the method should be awaited.
|
|
497
497
|
|
|
@@ -507,13 +507,13 @@ cdef bint _should_await(_ASyncFunction self, dict kwargs):
|
|
|
507
507
|
return is_sync(flag, kwargs, pop_flag=True) # type: ignore [arg-type]
|
|
508
508
|
elif default := self.get_default():
|
|
509
509
|
return default == "sync"
|
|
510
|
-
elif _is_a_sync_instance(self.
|
|
511
|
-
|
|
512
|
-
return
|
|
510
|
+
elif _is_a_sync_instance(instance := self.__c_self__()):
|
|
511
|
+
instance: "ASyncABC"
|
|
512
|
+
return instance.__a_sync_should_await__(kwargs)
|
|
513
513
|
return self._is_async_def
|
|
514
514
|
|
|
515
515
|
|
|
516
|
-
class
|
|
516
|
+
cdef class _ASyncBoundMethod(_ASyncFunction):
|
|
517
517
|
"""
|
|
518
518
|
A bound method that can be called both synchronously and asynchronously.
|
|
519
519
|
|
|
@@ -541,26 +541,13 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
541
541
|
- :class:`ASyncMethodDescriptor`
|
|
542
542
|
- :class:`ASyncFunction`
|
|
543
543
|
"""
|
|
544
|
-
|
|
545
|
-
# NOTE: this is created by the Descriptor
|
|
546
|
-
|
|
547
|
-
_cache_handle: TimerHandle = None
|
|
548
|
-
"""An asyncio handle used to pop the bound method from `instance.__dict__` 5 minutes after its last use."""
|
|
549
|
-
|
|
550
|
-
__weakself__: "ref[I]"
|
|
551
|
-
"""A weak reference to the instance the function is bound to."""
|
|
552
|
-
|
|
553
|
-
__wrapped__: AnyFn[Concatenate[I, P], T]
|
|
554
|
-
"""The original unbound method that was wrapped."""
|
|
555
|
-
|
|
556
|
-
__slots__ = "_is_async_def", "__weakself__"
|
|
557
|
-
|
|
544
|
+
|
|
558
545
|
def __init__(
|
|
559
|
-
|
|
546
|
+
self,
|
|
560
547
|
instance: I,
|
|
561
548
|
unbound: AnyFn[Concatenate[I, P], T],
|
|
562
|
-
async_def
|
|
563
|
-
|
|
549
|
+
bint async_def,
|
|
550
|
+
dict modifiers,
|
|
564
551
|
) -> None:
|
|
565
552
|
"""
|
|
566
553
|
Initialize the bound method.
|
|
@@ -583,6 +570,9 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
583
570
|
>>> obj = MyClass(42)
|
|
584
571
|
>>> bound_method = ASyncBoundMethod(obj, MyClass.my_method, True)
|
|
585
572
|
"""
|
|
573
|
+
# NOTE: This will be created by the Descriptor
|
|
574
|
+
self._cache_handle = None
|
|
575
|
+
|
|
586
576
|
# First we bind the method to a weak reference
|
|
587
577
|
# - bind and create a strong reference to the cache handle method
|
|
588
578
|
weakref_callback = self.__cancel_cache_handle
|
|
@@ -609,15 +599,17 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
609
599
|
>>> repr(bound_method)
|
|
610
600
|
'<ASyncBoundMethod for function module.ClassName.method_name bound to instance>'
|
|
611
601
|
"""
|
|
612
|
-
cdef object instance_type
|
|
602
|
+
cdef object instance, instance_type
|
|
603
|
+
|
|
613
604
|
try:
|
|
614
|
-
|
|
605
|
+
instance = self.__c_self__()
|
|
606
|
+
instance_type = type(instance)
|
|
615
607
|
return "<{} for function {}.{}.{} bound to {}>".format(
|
|
616
608
|
self.__class__.__name__,
|
|
617
609
|
instance_type.__module__,
|
|
618
610
|
instance_type.__name__,
|
|
619
611
|
self.__name__,
|
|
620
|
-
|
|
612
|
+
instance,
|
|
621
613
|
)
|
|
622
614
|
except ReferenceError:
|
|
623
615
|
return "<{} for function COLLECTED.COLLECTED.{} bound to {}>".format(
|
|
@@ -626,22 +618,6 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
626
618
|
self.__weakself__
|
|
627
619
|
)
|
|
628
620
|
|
|
629
|
-
@overload
|
|
630
|
-
def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
|
|
631
|
-
@overload
|
|
632
|
-
def __call__(
|
|
633
|
-
self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
|
|
634
|
-
) -> Coroutine[Any, Any, T]: ...
|
|
635
|
-
@overload
|
|
636
|
-
def __call__(
|
|
637
|
-
self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs
|
|
638
|
-
) -> T: ...
|
|
639
|
-
@overload
|
|
640
|
-
def __call__(
|
|
641
|
-
self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
|
|
642
|
-
) -> Coroutine[Any, Any, T]: ...
|
|
643
|
-
@overload
|
|
644
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]: ...
|
|
645
621
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]:
|
|
646
622
|
"""
|
|
647
623
|
Call the bound method.
|
|
@@ -664,7 +640,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
664
640
|
_logger_log(DEBUG, "calling %s with args: %s kwargs: %s", (self, args, kwargs))
|
|
665
641
|
# This could either be a coroutine or a return value from an awaited coroutine,
|
|
666
642
|
# depending on if an overriding flag kwarg was passed into the function call.
|
|
667
|
-
retval = coro = _ASyncFunction.__call__(self, self.
|
|
643
|
+
retval = coro = _ASyncFunction.__call__(self, self.__c_self__(), *args, **kwargs)
|
|
668
644
|
if not isawaitable(retval):
|
|
669
645
|
# The coroutine was already awaited due to the use of an overriding flag kwarg.
|
|
670
646
|
# We can return the value.
|
|
@@ -683,7 +659,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
683
659
|
return retval # type: ignore [call-overload, return-value]
|
|
684
660
|
|
|
685
661
|
@property
|
|
686
|
-
def __self__(self) ->
|
|
662
|
+
def __self__(self) -> object:
|
|
687
663
|
"""
|
|
688
664
|
Get the instance the method is bound to.
|
|
689
665
|
|
|
@@ -695,6 +671,9 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
695
671
|
>>> bound_method.__self__
|
|
696
672
|
<MyClass instance>
|
|
697
673
|
"""
|
|
674
|
+
return self.__c_self__()
|
|
675
|
+
|
|
676
|
+
cdef object __c_self__(self):
|
|
698
677
|
cdef PyObject *self_ptr
|
|
699
678
|
if PyWeakref_GetRef(<PyObject*>self.__weakself__, &self_ptr) == 1:
|
|
700
679
|
# 1 is success
|
|
@@ -725,6 +704,9 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
725
704
|
>>> task_mapping = bound_method.map(iterable1, iterable2, concurrency=5)
|
|
726
705
|
TODO briefly include how someone would then use task_mapping
|
|
727
706
|
"""
|
|
707
|
+
return self.c_map(iterables, concurrency, task_name, kwargs)
|
|
708
|
+
|
|
709
|
+
cdef object c_map(self, tuple iterables, object concurrency, str task_name, dict kwargs):
|
|
728
710
|
if TaskMapping is None:
|
|
729
711
|
_import_TaskMapping()
|
|
730
712
|
|
|
@@ -752,9 +734,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
752
734
|
>>> bound_method = ASyncBoundMethod(instance, my_function, True)
|
|
753
735
|
>>> result = await bound_method.any(iterable1, iterable2)
|
|
754
736
|
"""
|
|
755
|
-
return await self.
|
|
756
|
-
*iterables, concurrency=concurrency, task_name=task_name, **kwargs
|
|
757
|
-
).any(pop=True, sync=False)
|
|
737
|
+
return await self.c_map(iterables, concurrency, task_name, kwargs).any(pop=True, sync=False)
|
|
758
738
|
|
|
759
739
|
async def all(
|
|
760
740
|
self,
|
|
@@ -776,9 +756,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
776
756
|
>>> bound_method = ASyncBoundMethod(instance, my_function, True)
|
|
777
757
|
>>> result = await bound_method.all(iterable1, iterable2)
|
|
778
758
|
"""
|
|
779
|
-
return await self.
|
|
780
|
-
*iterables, concurrency=concurrency, task_name=task_name, **kwargs
|
|
781
|
-
).all(pop=True, sync=False)
|
|
759
|
+
return await self.c_map(iterables, concurrency, task_name, kwargs).all(pop=True, sync=False)
|
|
782
760
|
|
|
783
761
|
async def min(
|
|
784
762
|
self,
|
|
@@ -800,9 +778,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
800
778
|
>>> bound_method = ASyncBoundMethod(instance, my_function, True)
|
|
801
779
|
>>> result = await bound_method.min(iterable1, iterable2)
|
|
802
780
|
"""
|
|
803
|
-
return await self.
|
|
804
|
-
*iterables, concurrency=concurrency, task_name=task_name, **kwargs
|
|
805
|
-
).min(pop=True, sync=False)
|
|
781
|
+
return await self.c_map(iterables, concurrency, task_name, kwargs).min(pop=True, sync=False)
|
|
806
782
|
|
|
807
783
|
async def max(
|
|
808
784
|
self,
|
|
@@ -824,9 +800,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
824
800
|
>>> bound_method = ASyncBoundMethod(instance, my_function, True)
|
|
825
801
|
>>> result = await bound_method.max(iterable1, iterable2)
|
|
826
802
|
"""
|
|
827
|
-
return await self.
|
|
828
|
-
*iterables, concurrency=concurrency, task_name=task_name, **kwargs
|
|
829
|
-
).max(pop=True, sync=False)
|
|
803
|
+
return await self.c_map(iterables, concurrency, task_name, kwargs).max(pop=True, sync=False)
|
|
830
804
|
|
|
831
805
|
async def sum(
|
|
832
806
|
self,
|
|
@@ -848,9 +822,57 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
848
822
|
>>> bound_method = ASyncBoundMethod(instance, my_function, True)
|
|
849
823
|
>>> result = await bound_method.sum(iterable1, iterable2)
|
|
850
824
|
"""
|
|
851
|
-
return await self.
|
|
852
|
-
|
|
853
|
-
|
|
825
|
+
return await self.c_map(iterables, concurrency, task_name, kwargs).sum(pop=True, sync=False)
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
class ASyncBoundMethod(_ASyncBoundMethod, Generic[I, P, T]):
|
|
829
|
+
def __init__(
|
|
830
|
+
_ASyncFunction self,
|
|
831
|
+
instance: I,
|
|
832
|
+
unbound: AnyFn[Concatenate[I, P], T],
|
|
833
|
+
async_def: bool,
|
|
834
|
+
**modifiers: Unpack[ModifierKwargs],
|
|
835
|
+
) -> None:
|
|
836
|
+
"""
|
|
837
|
+
Initialize the bound method.
|
|
838
|
+
|
|
839
|
+
Args:
|
|
840
|
+
instance: The instance to bind the method to.
|
|
841
|
+
unbound: The unbound function.
|
|
842
|
+
async_def: Whether the original function is an async def.
|
|
843
|
+
**modifiers: Additional modifiers for the function.
|
|
844
|
+
|
|
845
|
+
Examples:
|
|
846
|
+
>>> class MyClass:
|
|
847
|
+
... def __init__(self, value):
|
|
848
|
+
... self.value = value
|
|
849
|
+
...
|
|
850
|
+
... @ASyncMethodDescriptor
|
|
851
|
+
... async def my_method(self):
|
|
852
|
+
... return self.value
|
|
853
|
+
...
|
|
854
|
+
>>> obj = MyClass(42)
|
|
855
|
+
>>> bound_method = ASyncBoundMethod(obj, MyClass.my_method, True)
|
|
856
|
+
"""
|
|
857
|
+
_ASyncBoundMethod.__init__(self, instance, unbound, async_def, modifiers)
|
|
858
|
+
update_wrapper(self, unbound)
|
|
859
|
+
|
|
860
|
+
@overload
|
|
861
|
+
def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
|
|
862
|
+
@overload
|
|
863
|
+
def __call__(
|
|
864
|
+
self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
|
|
865
|
+
) -> Coroutine[Any, Any, T]: ...
|
|
866
|
+
@overload
|
|
867
|
+
def __call__(
|
|
868
|
+
self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs
|
|
869
|
+
) -> T: ...
|
|
870
|
+
@overload
|
|
871
|
+
def __call__(
|
|
872
|
+
self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
|
|
873
|
+
) -> Coroutine[Any, Any, T]: ...
|
|
874
|
+
@overload
|
|
875
|
+
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]: ...
|
|
854
876
|
|
|
855
877
|
def __cancel_cache_handle(self, instance: I) -> None:
|
|
856
878
|
"""
|
|
@@ -866,7 +888,7 @@ class ASyncBoundMethod(function.ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
866
888
|
handle = self._cache_handle
|
|
867
889
|
if handle is not None:
|
|
868
890
|
cancel_handle(handle)
|
|
869
|
-
|
|
891
|
+
|
|
870
892
|
|
|
871
893
|
class ASyncBoundMethodSyncDefault(ASyncBoundMethod[I, P, T]):
|
|
872
894
|
"""
|
|
@@ -912,18 +934,19 @@ class ASyncBoundMethodSyncDefault(ASyncBoundMethod[I, P, T]):
|
|
|
912
934
|
@overload
|
|
913
935
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ...
|
|
914
936
|
|
|
915
|
-
__call__
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
937
|
+
def __call__(self, *args, **kwargs):
|
|
938
|
+
"""
|
|
939
|
+
Call the bound method with synchronous default behavior.
|
|
940
|
+
|
|
941
|
+
Args:
|
|
942
|
+
*args: Positional arguments.
|
|
943
|
+
**kwargs: Keyword arguments.
|
|
944
|
+
|
|
945
|
+
Examples:
|
|
946
|
+
>>> bound_method = ASyncBoundMethodSyncDefault(instance, my_function, True)
|
|
947
|
+
>>> bound_method(arg1, arg2, kwarg1=value1)
|
|
948
|
+
"""
|
|
949
|
+
return _ASyncBoundMethod.__call__(self, *args, **kwargs)
|
|
927
950
|
|
|
928
951
|
|
|
929
952
|
class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
|
|
@@ -970,18 +993,19 @@ class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
|
|
|
970
993
|
@overload
|
|
971
994
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T]: ...
|
|
972
995
|
|
|
973
|
-
__call__
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
996
|
+
def __call__(self, *args, **kwargs):
|
|
997
|
+
"""
|
|
998
|
+
Call the bound method with asynchronous default behavior.
|
|
999
|
+
|
|
1000
|
+
Args:
|
|
1001
|
+
*args: Positional arguments.
|
|
1002
|
+
**kwargs: Keyword arguments.
|
|
1003
|
+
|
|
1004
|
+
Examples:
|
|
1005
|
+
>>> bound_method = ASyncBoundMethodAsyncDefault(instance, my_function, True)
|
|
1006
|
+
>>> await bound_method(arg1, arg2, kwarg1=value1)
|
|
1007
|
+
"""
|
|
1008
|
+
return _ASyncBoundMethod.__call__(self, *args, **kwargs)
|
|
985
1009
|
|
|
986
1010
|
|
|
987
1011
|
cdef inline void _import_ASyncABC():
|
|
Binary file
|