ez-a-sync 0.23.4__tar.gz → 0.23.6__tar.gz
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.
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/PKG-INFO +1 -1
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/function.py +20 -9
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/method.py +39 -72
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/property.py +22 -20
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/ez_a_sync.egg-info/PKG-INFO +1 -1
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.coverage +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.github/workflows/black.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.github/workflows/codeql.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.github/workflows/docs.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.github/workflows/mypy.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.github/workflows/pytest.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.github/workflows/release.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.gitignore +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/.sourcery.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/LICENSE.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/Makefile +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/README.md +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/TODO +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/ENVIRONMENT_VARIABLES.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/_smart.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/_typing.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_descriptor.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_flags.c +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_flags.pyi +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_flags.pyx +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_helpers.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_kwargs.c +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_kwargs.pyi +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_kwargs.pyx +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/_meta.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/abstract.c +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/abstract.pyi +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/abstract.pyx +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/base.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/config.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/decorator.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/cache/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/cache/memory.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/limiter.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/manager.c +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/manager.pyi +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/manager.pyx +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/modifiers/semaphores.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/a_sync/singleton.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/aliases.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/asyncio/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/asyncio/as_completed.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/asyncio/create_task.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/asyncio/gather.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/asyncio/utils.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/exceptions.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/executor.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/future.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/iter.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/_debug.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/_loggable.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/locks/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/locks/counter.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/locks/event.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/locks/prio_semaphore.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/locks/semaphore.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/primitives/queue.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/py.typed +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/sphinx/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/sphinx/ext.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/task.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/utils/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/a_sync/utils/iterators.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/Makefile +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/alabaster.css +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/basic.css +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/custom.css +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/doctools.js +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/documentation_options.js +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/file.png +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/language_data.js +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/minus.png +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/plus.png +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/pygments.css +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/searchtools.js +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/_build/html/_static/sphinx_highlight.js +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/conf.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/index.rst +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/docs/make.bat +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/ez_a_sync.egg-info/SOURCES.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/ez_a_sync.egg-info/dependency_links.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/ez_a_sync.egg-info/not-zip-safe +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/ez_a_sync.egg-info/requires.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/ez_a_sync.egg-info/top_level.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/pyproject.yaml +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/requirements-dev.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/requirements.txt +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/setup.cfg +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/setup.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/__init__.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/conftest.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/executor.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/fixtures.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_abstract.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_as_completed.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_base.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_cache.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_decorator.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_executor.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_future.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_gather.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_helpers.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_iter.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_limiter.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_meta.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_modified.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_semaphore.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_singleton.py +0 -0
- {ez_a_sync-0.23.4 → ez_a_sync-0.23.6}/tests/test_task.py +0 -0
|
@@ -808,13 +808,21 @@ class ASyncFunction(_ModifiedMixin, Generic[P, T]):
|
|
|
808
808
|
- :meth:`_await`
|
|
809
809
|
"""
|
|
810
810
|
|
|
811
|
-
|
|
811
|
+
modified_fn = self._modified_fn
|
|
812
|
+
await_helper = self._await
|
|
813
|
+
|
|
814
|
+
@functools.wraps(modified_fn)
|
|
812
815
|
def async_wrap(*args: P.args, **kwargs: P.kwargs) -> MaybeAwaitable[T]: # type: ignore [name-defined]
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
coro
|
|
817
|
-
|
|
816
|
+
# sourcery skip: assign-if-exp
|
|
817
|
+
# we dont want this so profiler outputs are more useful
|
|
818
|
+
|
|
819
|
+
# Must take place before coro is created, we're popping a kwarg.
|
|
820
|
+
should_await = self._run_sync(kwargs)
|
|
821
|
+
coro = modified_fn(*args, **kwargs)
|
|
822
|
+
if should_await:
|
|
823
|
+
return await_helper(coro)
|
|
824
|
+
else:
|
|
825
|
+
return coro
|
|
818
826
|
|
|
819
827
|
return async_wrap
|
|
820
828
|
|
|
@@ -833,11 +841,14 @@ class ASyncFunction(_ModifiedMixin, Generic[P, T]):
|
|
|
833
841
|
- :meth:`_asyncified`
|
|
834
842
|
"""
|
|
835
843
|
|
|
836
|
-
|
|
844
|
+
modified_fn = self._modified_fn
|
|
845
|
+
asyncified = self._asyncified
|
|
846
|
+
|
|
847
|
+
@functools.wraps(modified_fn)
|
|
837
848
|
def sync_wrap(*args: P.args, **kwargs: P.kwargs) -> MaybeAwaitable[T]: # type: ignore [name-defined]
|
|
838
849
|
if self._run_sync(kwargs):
|
|
839
|
-
return
|
|
840
|
-
return
|
|
850
|
+
return modified_fn(*args, **kwargs)
|
|
851
|
+
return asyncified(*args, **kwargs)
|
|
841
852
|
|
|
842
853
|
return sync_wrap
|
|
843
854
|
|
|
@@ -9,6 +9,7 @@ asynchronously based on various conditions and configurations.
|
|
|
9
9
|
# mypy: disable-error-code=valid-type
|
|
10
10
|
# mypy: disable-error-code=misc
|
|
11
11
|
import functools
|
|
12
|
+
import heapq
|
|
12
13
|
import logging
|
|
13
14
|
import weakref
|
|
14
15
|
from inspect import isawaitable
|
|
@@ -156,8 +157,7 @@ class ASyncMethodDescriptor(ASyncDescriptor[I, P, T]):
|
|
|
156
157
|
)
|
|
157
158
|
instance.__dict__[self.field_name] = bound
|
|
158
159
|
logger.debug("new bound method: %s", bound)
|
|
159
|
-
|
|
160
|
-
bound._cache_handle = self._get_cache_handle(instance)
|
|
160
|
+
self._update_cache_handle(instance, bound)
|
|
161
161
|
return bound
|
|
162
162
|
|
|
163
163
|
def __set__(self, instance, value):
|
|
@@ -211,24 +211,23 @@ class ASyncMethodDescriptor(ASyncDescriptor[I, P, T]):
|
|
|
211
211
|
"""
|
|
212
212
|
return asyncio.iscoroutinefunction(self.__wrapped__)
|
|
213
213
|
|
|
214
|
-
def
|
|
214
|
+
def _update_cache_handle(self, instance, bound: "ASyncBoundMethod") -> None:
|
|
215
215
|
"""
|
|
216
|
-
|
|
216
|
+
Update the TTL for the cache handle for the instance.
|
|
217
217
|
|
|
218
218
|
Args:
|
|
219
219
|
instance: The instance to create a cache handle for.
|
|
220
|
-
|
|
221
|
-
Returns:
|
|
222
|
-
A timer handle for cache management.
|
|
223
|
-
|
|
224
|
-
Examples:
|
|
225
|
-
>>> descriptor = ASyncMethodDescriptor(my_function)
|
|
226
|
-
>>> cache_handle = descriptor._get_cache_handle(instance)
|
|
220
|
+
bound: The bound method we are caching.
|
|
227
221
|
"""
|
|
228
|
-
#
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
222
|
+
# Handler for popping unused bound methods from bound method cache
|
|
223
|
+
loop = asyncio.get_event_loop()
|
|
224
|
+
if handle := bound._cache_handle:
|
|
225
|
+
handle._when = loop.time() + 300
|
|
226
|
+
else:
|
|
227
|
+
# NOTE: use `instance.__dict__.pop` instead of `delattr` so we don't create a strong ref to `instance`
|
|
228
|
+
bound._cache_handle = loop.call_at(
|
|
229
|
+
loop.time() + 300, instance.__dict__.pop, self.field_name
|
|
230
|
+
)
|
|
232
231
|
|
|
233
232
|
|
|
234
233
|
@final
|
|
@@ -314,8 +313,7 @@ class ASyncMethodDescriptorSyncDefault(ASyncMethodDescriptor[I, P, T]):
|
|
|
314
313
|
)
|
|
315
314
|
instance.__dict__[self.field_name] = bound
|
|
316
315
|
logger.debug("new bound method: %s", bound)
|
|
317
|
-
|
|
318
|
-
bound._cache_handle = self._get_cache_handle(instance)
|
|
316
|
+
self._update_cache_handle(instance, bound)
|
|
319
317
|
return bound
|
|
320
318
|
|
|
321
319
|
|
|
@@ -399,8 +397,7 @@ class ASyncMethodDescriptorAsyncDefault(ASyncMethodDescriptor[I, P, T]):
|
|
|
399
397
|
)
|
|
400
398
|
instance.__dict__[self.field_name] = bound
|
|
401
399
|
logger.debug("new bound method: %s", bound)
|
|
402
|
-
|
|
403
|
-
bound._cache_handle = self._get_cache_handle(instance)
|
|
400
|
+
self._update_cache_handle(instance, bound)
|
|
404
401
|
return bound
|
|
405
402
|
|
|
406
403
|
|
|
@@ -435,7 +432,7 @@ class ASyncBoundMethod(ASyncFunction[P, T], Generic[I, P, T]):
|
|
|
435
432
|
|
|
436
433
|
# NOTE: this is created by the Descriptor
|
|
437
434
|
|
|
438
|
-
_cache_handle: asyncio.TimerHandle
|
|
435
|
+
_cache_handle: asyncio.TimerHandle = None
|
|
439
436
|
"""An asyncio handle used to pop the bound method from `instance.__dict__` 5 minutes after its last use."""
|
|
440
437
|
|
|
441
438
|
__weakself__: "weakref.ref[I]"
|
|
@@ -795,22 +792,6 @@ class ASyncBoundMethodSyncDefault(ASyncBoundMethod[I, P, T]):
|
|
|
795
792
|
- :class:`ASyncMethodDescriptorSyncDefault`
|
|
796
793
|
"""
|
|
797
794
|
|
|
798
|
-
def __get__(
|
|
799
|
-
self, instance: Optional[I], owner: Type[I]
|
|
800
|
-
) -> ASyncFunctionSyncDefault[P, T]:
|
|
801
|
-
"""
|
|
802
|
-
Get the bound method or descriptor.
|
|
803
|
-
|
|
804
|
-
Args:
|
|
805
|
-
instance: The instance to bind the method to, or None.
|
|
806
|
-
owner: The owner class.
|
|
807
|
-
|
|
808
|
-
Examples:
|
|
809
|
-
>>> descriptor = ASyncMethodDescriptorSyncDefault(my_function)
|
|
810
|
-
>>> bound_method = descriptor.__get__(instance, MyClass)
|
|
811
|
-
"""
|
|
812
|
-
return ASyncBoundMethod.__get__(self, instance, owner)
|
|
813
|
-
|
|
814
795
|
@overload
|
|
815
796
|
def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
|
|
816
797
|
@overload
|
|
@@ -827,19 +808,19 @@ class ASyncBoundMethodSyncDefault(ASyncBoundMethod[I, P, T]):
|
|
|
827
808
|
) -> Coroutine[Any, Any, T]: ...
|
|
828
809
|
@overload
|
|
829
810
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ...
|
|
830
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
|
|
831
|
-
"""
|
|
832
|
-
Call the bound method with synchronous default behavior.
|
|
833
811
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
812
|
+
__call__ = ASyncBoundMethod.__call__
|
|
813
|
+
"""
|
|
814
|
+
Call the bound method with synchronous default behavior.
|
|
837
815
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
816
|
+
Args:
|
|
817
|
+
*args: Positional arguments.
|
|
818
|
+
**kwargs: Keyword arguments.
|
|
819
|
+
|
|
820
|
+
Examples:
|
|
821
|
+
>>> bound_method = ASyncBoundMethodSyncDefault(instance, my_function, True)
|
|
822
|
+
>>> bound_method(arg1, arg2, kwarg1=value1)
|
|
823
|
+
"""
|
|
843
824
|
|
|
844
825
|
|
|
845
826
|
class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
|
|
@@ -869,20 +850,6 @@ class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
|
|
|
869
850
|
- :class:`ASyncMethodDescriptorAsyncDefault`
|
|
870
851
|
"""
|
|
871
852
|
|
|
872
|
-
def __get__(self, instance: I, owner: Type[I]) -> ASyncFunctionAsyncDefault[P, T]:
|
|
873
|
-
"""
|
|
874
|
-
Get the bound method or descriptor.
|
|
875
|
-
|
|
876
|
-
Args:
|
|
877
|
-
instance: The instance to bind the method to.
|
|
878
|
-
owner: The owner class.
|
|
879
|
-
|
|
880
|
-
Examples:
|
|
881
|
-
>>> descriptor = ASyncMethodDescriptorAsyncDefault(my_function)
|
|
882
|
-
>>> bound_method = descriptor.__get__(instance, MyClass)
|
|
883
|
-
"""
|
|
884
|
-
return ASyncBoundMethod.__get__(self, instance, owner)
|
|
885
|
-
|
|
886
853
|
@overload
|
|
887
854
|
def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
|
|
888
855
|
@overload
|
|
@@ -899,16 +866,16 @@ class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
|
|
|
899
866
|
) -> Coroutine[Any, Any, T]: ...
|
|
900
867
|
@overload
|
|
901
868
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T]: ...
|
|
902
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T]:
|
|
903
|
-
"""
|
|
904
|
-
Call the bound method with asynchronous default behavior.
|
|
905
869
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
870
|
+
__call__ = ASyncBoundMethod.__call__
|
|
871
|
+
"""
|
|
872
|
+
Call the bound method with asynchronous default behavior.
|
|
909
873
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
874
|
+
Args:
|
|
875
|
+
*args: Positional arguments.
|
|
876
|
+
**kwargs: Keyword arguments.
|
|
877
|
+
|
|
878
|
+
Examples:
|
|
879
|
+
>>> bound_method = ASyncBoundMethodAsyncDefault(instance, my_function, True)
|
|
880
|
+
>>> await bound_method(arg1, arg2, kwarg1=value1)
|
|
881
|
+
"""
|
|
@@ -210,17 +210,17 @@ class ASyncPropertyDescriptorSyncDefault(property[I, T]):
|
|
|
210
210
|
def __get__(self, instance: None, owner: Type[I]) -> Self: ...
|
|
211
211
|
@overload
|
|
212
212
|
def __get__(self, instance: I, owner: Type[I]) -> T: ...
|
|
213
|
-
def __get__(self, instance: Optional[I], owner: Type[I]) -> Union[Self, T]:
|
|
214
|
-
"""Retrieves the property value, either synchronously or asynchronously.
|
|
215
213
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
owner: The owner class of the property.
|
|
214
|
+
__get__ = _ASyncPropertyDescriptorBase.__get__
|
|
215
|
+
"""Retrieves the property value, either synchronously or asynchronously.
|
|
219
216
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
217
|
+
Args:
|
|
218
|
+
instance: The instance from which the property is accessed.
|
|
219
|
+
owner: The owner class of the property.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
The property value, either as an awaitable or directly.
|
|
223
|
+
"""
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
@final
|
|
@@ -474,17 +474,17 @@ class ASyncCachedPropertyDescriptorSyncDefault(cached_property[I, T]):
|
|
|
474
474
|
def __get__(self, instance: None, owner: Type[I]) -> Self: ...
|
|
475
475
|
@overload
|
|
476
476
|
def __get__(self, instance: I, owner: Type[I]) -> T: ...
|
|
477
|
-
def __get__(self, instance: Optional[I], owner: Type[I]) -> Union[Self, T]:
|
|
478
|
-
"""Retrieves the cached property value, either synchronously or asynchronously.
|
|
479
477
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
owner: The owner class of the property.
|
|
478
|
+
__get__ = _ASyncPropertyDescriptorBase.__get__
|
|
479
|
+
"""Retrieves the cached property value, either synchronously or asynchronously.
|
|
483
480
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
481
|
+
Args:
|
|
482
|
+
instance: The instance from which the property is accessed.
|
|
483
|
+
owner: The owner class of the property.
|
|
484
|
+
|
|
485
|
+
Returns:
|
|
486
|
+
The cached property value, either as an awaitable or directly.
|
|
487
|
+
"""
|
|
488
488
|
|
|
489
489
|
|
|
490
490
|
@final
|
|
@@ -667,7 +667,9 @@ class HiddenMethod(ASyncBoundMethodAsyncDefault[I, Tuple[()], T]):
|
|
|
667
667
|
|
|
668
668
|
def __await__(self) -> Generator[Any, None, T]:
|
|
669
669
|
"""Returns an awaitable for the method."""
|
|
670
|
-
|
|
670
|
+
# NOTE: self(sync=False).__await__() would be cleaner but requires way more compute for no real gain
|
|
671
|
+
logger.debug("awaiting %s", self)
|
|
672
|
+
return self.fn(self.__self__, sync=False).__await__()
|
|
671
673
|
|
|
672
674
|
|
|
673
675
|
@final
|
|
@@ -728,7 +730,7 @@ class HiddenMethodDescriptor(ASyncMethodDescriptorAsyncDefault[I, Tuple[()], T])
|
|
|
728
730
|
)
|
|
729
731
|
instance.__dict__[self.field_name] = bound
|
|
730
732
|
logger.debug("new hidden method: %s", bound)
|
|
731
|
-
|
|
733
|
+
self._update_cache_handle(instance, bound)
|
|
732
734
|
return bound
|
|
733
735
|
|
|
734
736
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|