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
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ctypedef str FieldName
|
|
2
|
+
ctypedef object CacheValue
|
|
3
|
+
|
|
4
|
+
cdef public str ASYNC_PROPERTY_ATTR = "__async_property__"
|
|
5
|
+
|
|
6
|
+
cdef class AsyncCachedPropertyInstanceState:
|
|
7
|
+
cdef readonly dict[FieldName, CacheValue] cache
|
|
8
|
+
cdef readonly object locks
|
|
9
|
+
cdef object get_lock(self, str field_name)
|
|
10
|
+
cdef object get_cache_value(self, str field_name)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from asyncio import Lock
|
|
2
|
+
from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
from a_sync.async_property.proxy import AwaitableOnly, AwaitableProxy
|
|
5
|
+
|
|
6
|
+
ProxyType = Union[AwaitableOnly[__T], AwaitableProxy[__T]]
|
|
7
|
+
|
|
8
|
+
FieldName = str
|
|
9
|
+
|
|
10
|
+
__I = TypeVar("__I")
|
|
11
|
+
__T = TypeVar("__T")
|
|
12
|
+
|
|
13
|
+
def async_cached_property(
|
|
14
|
+
func: Callable[[__I], __T], *args, **kwargs
|
|
15
|
+
) -> "AsyncCachedPropertyDescriptor[__I, __T]": ...
|
|
16
|
+
|
|
17
|
+
class AsyncCachedPropertyInstanceState(Generic[__T]):
|
|
18
|
+
cache: Dict[FieldName, __T]
|
|
19
|
+
locks: Dict[FieldName, Lock]
|
|
20
|
+
|
|
21
|
+
class AsyncCachedPropertyDescriptor(Generic[__I, __T]):
|
|
22
|
+
field_name: FieldName
|
|
23
|
+
_load_value: Callable[[__I], __T]
|
|
24
|
+
_fget: Callable[[__I], __T]
|
|
25
|
+
_fset: Optional[Callable]
|
|
26
|
+
_fdel: Optional[Callable]
|
|
27
|
+
def __init__(
|
|
28
|
+
self, _fget: Callable[[__I], __T], _fset=None, _fdel=None, field_name=None
|
|
29
|
+
) -> None: ...
|
|
30
|
+
def __set_name__(self, owner, name) -> None: ...
|
|
31
|
+
def __get__(self, instance: __I, owner) -> ProxyType[__T]: ...
|
|
32
|
+
def __set__(self, instance: __I, value): ...
|
|
33
|
+
def __delete__(self, instance: __I) -> None: ...
|
|
34
|
+
def setter(self, method): ...
|
|
35
|
+
def deleter(self, method): ...
|
|
36
|
+
def _check_method_name(self, method, method_type) -> None: ...
|
|
37
|
+
def _check_method_sync(self, method, method_type) -> None: ...
|
|
38
|
+
def get_instance_state(self, instance) -> AsyncCachedPropertyInstanceState[__T]: ...
|
|
39
|
+
def get_lock(self, instance: __I) -> Lock: ...
|
|
40
|
+
def get_cache(self, instance: __I) -> Dict[field_name, Any]: ...
|
|
41
|
+
def has_cache_value(self, instance: __I) -> bool: ...
|
|
42
|
+
def get_cache_value(self, instance: __I) -> __T: ...
|
|
43
|
+
def set_cache_value(self, instance: __I, value: __T) -> None: ...
|
|
44
|
+
def del_cache_value(self, instance: __I) -> None: ...
|
|
45
|
+
def get_loader(self, instance: __I) -> Callable[[], __T]: ...
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import collections
|
|
3
|
+
import functools
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from a_sync._smart cimport shield
|
|
7
|
+
from a_sync.async_property.proxy import AwaitableProxy
|
|
8
|
+
from a_sync.async_property.proxy cimport AwaitableOnly
|
|
9
|
+
from a_sync.functools cimport update_wrapper
|
|
10
|
+
|
|
11
|
+
# cdef asyncio
|
|
12
|
+
cdef object iscoroutinefunction = asyncio.iscoroutinefunction
|
|
13
|
+
cdef object Lock = asyncio.Lock
|
|
14
|
+
del asyncio
|
|
15
|
+
|
|
16
|
+
# cdef collections
|
|
17
|
+
cdef object defaultdict = collections.defaultdict
|
|
18
|
+
del collections
|
|
19
|
+
|
|
20
|
+
# cdef functools
|
|
21
|
+
cdef object wraps = functools.wraps
|
|
22
|
+
del functools
|
|
23
|
+
|
|
24
|
+
# cdef typing
|
|
25
|
+
cdef object Any = typing.Any
|
|
26
|
+
cdef object DefaultDict = typing.DefaultDict
|
|
27
|
+
cdef object Dict = typing.Dict
|
|
28
|
+
del typing
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
cdef object _AwaitableProxy = AwaitableProxy
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def async_cached_property(func, *args, **kwargs) -> "AsyncCachedPropertyDescriptor":
|
|
35
|
+
assert iscoroutinefunction(func), "Can only use with async def"
|
|
36
|
+
return __AsyncCachedPropertyDescriptor(func, *args, **kwargs)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
cdef class AsyncCachedPropertyInstanceState:
|
|
40
|
+
def __cinit__(self) -> None:
|
|
41
|
+
self.cache: Dict[FieldName, Any] = {}
|
|
42
|
+
self.locks: DefaultDict[FieldName, Lock] = defaultdict(Lock)
|
|
43
|
+
|
|
44
|
+
cdef object get_lock(self, str field_name):
|
|
45
|
+
return self.locks[field_name]
|
|
46
|
+
|
|
47
|
+
cdef object get_cache_value(self, str field_name):
|
|
48
|
+
return self.cache[field_name]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class AsyncCachedPropertyDescriptor:
|
|
52
|
+
_load_value = None
|
|
53
|
+
|
|
54
|
+
def __init__(self, _fget, _fset=None, _fdel=None, field_name=None) -> None:
|
|
55
|
+
self._fget = _fget
|
|
56
|
+
self._fset = _fset
|
|
57
|
+
self._fdel = _fdel
|
|
58
|
+
self.field_name = field_name or _fget.__name__
|
|
59
|
+
|
|
60
|
+
update_wrapper(self, _fget)
|
|
61
|
+
self._check_method_sync(_fset, "setter")
|
|
62
|
+
self._check_method_sync(_fdel, "deleter")
|
|
63
|
+
|
|
64
|
+
def __set_name__(self, owner, name):
|
|
65
|
+
self.field_name = name
|
|
66
|
+
|
|
67
|
+
def __get__(self, instance, owner):
|
|
68
|
+
if instance is None:
|
|
69
|
+
return self
|
|
70
|
+
cache = (<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).cache
|
|
71
|
+
if self.field_name in cache:
|
|
72
|
+
return _AwaitableProxy(cache[self.field_name])
|
|
73
|
+
return AwaitableOnly(self.get_loader(instance))
|
|
74
|
+
|
|
75
|
+
def __set__(self, instance, value):
|
|
76
|
+
if self._fset is not None:
|
|
77
|
+
self._fset(instance, value)
|
|
78
|
+
self.set_cache_value(instance, value)
|
|
79
|
+
|
|
80
|
+
def __delete__(self, instance):
|
|
81
|
+
if self._fdel is not None:
|
|
82
|
+
self._fdel(instance)
|
|
83
|
+
self.del_cache_value(instance)
|
|
84
|
+
|
|
85
|
+
def setter(self, method):
|
|
86
|
+
self._check_method_name(method, "setter")
|
|
87
|
+
return type(self)(self._fget, method, self._fdel, self.field_name)
|
|
88
|
+
|
|
89
|
+
def deleter(self, method):
|
|
90
|
+
self._check_method_name(method, "deleter")
|
|
91
|
+
return type(self)(self._fget, self._fset, method, self.field_name)
|
|
92
|
+
|
|
93
|
+
def _check_method_name(self, method, method_type):
|
|
94
|
+
if method.__name__ != self.field_name:
|
|
95
|
+
raise AssertionError(f"@{self.field_name}.{method_type} name must match property name")
|
|
96
|
+
|
|
97
|
+
def _check_method_sync(self, method, method_type):
|
|
98
|
+
if method and iscoroutinefunction(method):
|
|
99
|
+
raise AssertionError(f"@{self.field_name}.{method_type} must be synchronous")
|
|
100
|
+
|
|
101
|
+
def get_instance_state(self, instance):
|
|
102
|
+
try:
|
|
103
|
+
return instance.__async_property__
|
|
104
|
+
except AttributeError:
|
|
105
|
+
state = AsyncCachedPropertyInstanceState()
|
|
106
|
+
instance.__async_property__ = state
|
|
107
|
+
return state
|
|
108
|
+
|
|
109
|
+
def get_lock(self, instance):
|
|
110
|
+
return (<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).get_lock(self.field_name)
|
|
111
|
+
|
|
112
|
+
def get_cache(self, instance):
|
|
113
|
+
return (<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).cache
|
|
114
|
+
|
|
115
|
+
def has_cache_value(self, instance):
|
|
116
|
+
return self.field_name in (<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).cache
|
|
117
|
+
|
|
118
|
+
def get_cache_value(self, instance):
|
|
119
|
+
return (<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).get_cache_value(self.field_name)
|
|
120
|
+
|
|
121
|
+
def set_cache_value(self, instance, value):
|
|
122
|
+
(<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).cache[self.field_name] = value
|
|
123
|
+
|
|
124
|
+
def del_cache_value(self, instance):
|
|
125
|
+
del (<AsyncCachedPropertyInstanceState>self.get_instance_state(instance)).cache[self.field_name]
|
|
126
|
+
|
|
127
|
+
def get_loader(self, instance):
|
|
128
|
+
cdef str field_name
|
|
129
|
+
|
|
130
|
+
loader = self._load_value
|
|
131
|
+
if loader is None:
|
|
132
|
+
|
|
133
|
+
field_name = self.field_name
|
|
134
|
+
_fget = self._fget
|
|
135
|
+
get_instance_state = self.get_instance_state
|
|
136
|
+
|
|
137
|
+
if self._fset is None:
|
|
138
|
+
@wraps(_fget)
|
|
139
|
+
async def loader(instance):
|
|
140
|
+
cdef AsyncCachedPropertyInstanceState instance_state
|
|
141
|
+
cdef dict[str, object] cache
|
|
142
|
+
|
|
143
|
+
instance_state = get_instance_state(instance)
|
|
144
|
+
locks: defaultdict = instance_state.locks
|
|
145
|
+
async with locks[field_name]:
|
|
146
|
+
cache = instance_state.cache
|
|
147
|
+
if field_name in cache:
|
|
148
|
+
return cache[field_name]
|
|
149
|
+
value = await _fget(instance)
|
|
150
|
+
cache[field_name] = value
|
|
151
|
+
dict.pop(locks, field_name)
|
|
152
|
+
return value
|
|
153
|
+
else:
|
|
154
|
+
_fset = self._fset
|
|
155
|
+
|
|
156
|
+
@wraps(_fget)
|
|
157
|
+
async def loader(instance):
|
|
158
|
+
cdef AsyncCachedPropertyInstanceState instance_state
|
|
159
|
+
cdef dict[str, object] cache
|
|
160
|
+
|
|
161
|
+
instance_state = get_instance_state(instance)
|
|
162
|
+
cache = instance_state.cache
|
|
163
|
+
locks: defaultdict = instance_state.locks
|
|
164
|
+
async with locks[field_name]:
|
|
165
|
+
if field_name in cache:
|
|
166
|
+
return cache[field_name]
|
|
167
|
+
value = await _fget(instance)
|
|
168
|
+
_fset(instance, value)
|
|
169
|
+
cache[field_name] = value
|
|
170
|
+
dict.pop(locks, field_name)
|
|
171
|
+
return value
|
|
172
|
+
|
|
173
|
+
self._load_value = loader
|
|
174
|
+
|
|
175
|
+
return lambda: shield(loader(instance))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
cdef object __AsyncCachedPropertyDescriptor = AsyncCachedPropertyDescriptor
|