ez-a-sync 0.32.29__cp310-cp310-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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-win_amd64.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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from typed_envs import EnvVarFactory
|
|
2
|
+
|
|
3
|
+
envs = EnvVarFactory("EZASYNC")
|
|
4
|
+
|
|
5
|
+
# We have some envs here to help you debug your custom class implementations
|
|
6
|
+
|
|
7
|
+
DEBUG_CLASS_NAME = envs.create_env("DEBUG_CLASS_NAME", str, default="", verbose=False)
|
|
8
|
+
"""str: The name of the class to debug.
|
|
9
|
+
|
|
10
|
+
If you're only interested in debugging a specific class, set this to the class name.
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
To debug a class named `MyClass`, set the environment variable:
|
|
14
|
+
|
|
15
|
+
.. code-block:: bash
|
|
16
|
+
|
|
17
|
+
export EZASYNC_DEBUG_CLASS_NAME=MyClass
|
|
18
|
+
|
|
19
|
+
See Also:
|
|
20
|
+
:func:`DEBUG_MODE` for enabling debug mode on all classes.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
DEBUG_MODE = envs.create_env("DEBUG_MODE", bool, default=bool(DEBUG_CLASS_NAME), verbose=False)
|
|
24
|
+
"""bool: Enables debug mode on all classes.
|
|
25
|
+
|
|
26
|
+
Set this environment variable to `True` to enable debug mode on all classes.
|
|
27
|
+
If `DEBUG_CLASS_NAME` is set to a non-empty string,
|
|
28
|
+
`DEBUG_MODE` will default to `True`.
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
To enable debug mode globally, set the environment variable:
|
|
32
|
+
|
|
33
|
+
.. code-block:: bash
|
|
34
|
+
|
|
35
|
+
export EZASYNC_DEBUG_MODE=True
|
|
36
|
+
|
|
37
|
+
If you have set `DEBUG_CLASS_NAME` to a specific class, `DEBUG_MODE` will
|
|
38
|
+
automatically be `True` unless `DEBUG_CLASS_NAME` is an empty string.
|
|
39
|
+
|
|
40
|
+
See Also:
|
|
41
|
+
:func:`DEBUG_CLASS_NAME` for debugging a specific class.
|
|
42
|
+
"""
|
a_sync/__init__.pxd
ADDED
a_sync/__init__.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module initializes the a_sync library by importing and organizing various components, utilities, and classes.
|
|
3
|
+
It provides a convenient and unified interface for asynchronous programming with a focus on flexibility and efficiency.
|
|
4
|
+
|
|
5
|
+
The `a_sync` library offers decorators and base classes to facilitate writing both synchronous and asynchronous code.
|
|
6
|
+
It includes the `@a_sync()` decorator and the `ASyncGenericBase` class, which allow for creating functions and classes
|
|
7
|
+
that can operate in both synchronous and asynchronous contexts. Additionally, it provides enhanced asyncio primitives,
|
|
8
|
+
such as queues and locks, with extra functionality.
|
|
9
|
+
|
|
10
|
+
Modules and components included:
|
|
11
|
+
- :mod:`~a_sync.aliases`, :mod:`~a_sync.exceptions`, :mod:`~a_sync.iter`, :mod:`~a_sync.task`: Core modules of the library.
|
|
12
|
+
- :class:`~ASyncGenericBase`, :class:`~ASyncGenericSingleton`, :func:`~a_sync`: Base classes and decorators for dual-context execution.
|
|
13
|
+
- :class:`~ASyncCachedPropertyDescriptor`, :class:`~ASyncPropertyDescriptor`, `cached_property`, `property`: Property descriptors for async properties.
|
|
14
|
+
- :func:`~as_completed`, :func:`~create_task`, :func:`~gather`: Enhanced asyncio functions.
|
|
15
|
+
- Executors: :class:`~AsyncThreadPoolExecutor`, :class:`~AsyncProcessPoolExecutor`, :class:`~PruningThreadPoolExecutor` for async execution.
|
|
16
|
+
- Iterators: :class:`~ASyncIterable`, :class:`~ASyncIterator`, :class:`~filter`, :class:`~sorted` for async iteration.
|
|
17
|
+
- Utilities: :func:`~all`, :func:`~any`, :func:`~as_yielded` for async utilities.
|
|
18
|
+
- :func:`~a_sync.a_sync.modifiers.semaphores.apply_semaphore`: Function to apply semaphores to coroutines.
|
|
19
|
+
- :class:`~TaskMapping`: A class for managing and asynchronously generating tasks based on input iterables.
|
|
20
|
+
|
|
21
|
+
Alias for backward compatibility:
|
|
22
|
+
- :class:`~ASyncBase` is an alias for :class:`~ASyncGenericBase`, which will be removed eventually, probably in version 0.1.0.
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
Using the `@a_sync` decorator:
|
|
26
|
+
>>> from a_sync import a_sync
|
|
27
|
+
>>> @a_sync
|
|
28
|
+
... async def my_function():
|
|
29
|
+
... return "Hello, World!"
|
|
30
|
+
>>> result = await my_function()
|
|
31
|
+
>>> print(result)
|
|
32
|
+
|
|
33
|
+
Using `ASyncGenericBase` for dual-context classes:
|
|
34
|
+
>>> from a_sync import ASyncGenericBase
|
|
35
|
+
>>> class MyClass(ASyncGenericBase):
|
|
36
|
+
... async def my_method(self):
|
|
37
|
+
... return "Hello from MyClass"
|
|
38
|
+
>>> obj = MyClass()
|
|
39
|
+
>>> result = await obj.my_method()
|
|
40
|
+
>>> print(result)
|
|
41
|
+
|
|
42
|
+
Using `TaskMapping` for asynchronous task management:
|
|
43
|
+
>>> from a_sync import TaskMapping
|
|
44
|
+
>>> async def fetch_data(url):
|
|
45
|
+
... return f"Data from {url}"
|
|
46
|
+
>>> tasks = TaskMapping(fetch_data, ['http://example.com', 'https://www.python.org'])
|
|
47
|
+
>>> async for key, result in tasks:
|
|
48
|
+
... print(f"Data for {key}: {result}")
|
|
49
|
+
|
|
50
|
+
See Also:
|
|
51
|
+
- :mod:`a_sync.a_sync`: Contains the core classes and decorators.
|
|
52
|
+
- :mod:`a_sync.asyncio`: Provides enhanced asyncio functions.
|
|
53
|
+
- :mod:`a_sync.primitives`: Includes modified versions of standard asyncio primitives.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
from a_sync import aliases, exceptions, functools, iter, task
|
|
57
|
+
from a_sync.a_sync import ASyncGenericBase, ASyncGenericSingleton, a_sync
|
|
58
|
+
from a_sync.a_sync.modifiers.semaphores import apply_semaphore
|
|
59
|
+
from a_sync.a_sync.property import ASyncCachedPropertyDescriptor, ASyncPropertyDescriptor
|
|
60
|
+
from a_sync.a_sync.property import ASyncCachedPropertyDescriptor as cached_property
|
|
61
|
+
from a_sync.a_sync.property import ASyncPropertyDescriptor as property
|
|
62
|
+
from a_sync.asyncio import as_completed, create_task, gather, cgather, igather
|
|
63
|
+
from a_sync.executor import *
|
|
64
|
+
from a_sync.executor import AsyncThreadPoolExecutor as ThreadPoolExecutor
|
|
65
|
+
from a_sync.executor import AsyncProcessPoolExecutor as ProcessPoolExecutor
|
|
66
|
+
from a_sync.future import ASyncFuture, future # type: ignore [attr-defined]
|
|
67
|
+
from a_sync.iter import ASyncFilter as filter
|
|
68
|
+
from a_sync.iter import ASyncSorter as sorted
|
|
69
|
+
from a_sync.iter import ASyncIterable, ASyncIterator
|
|
70
|
+
from a_sync.primitives import *
|
|
71
|
+
from a_sync.task import TaskMapping as map
|
|
72
|
+
from a_sync.task import TaskMapping
|
|
73
|
+
from a_sync.utils import all, any, as_yielded
|
|
74
|
+
|
|
75
|
+
# I alias the aliases for your convenience.
|
|
76
|
+
# I prefer "aka" but its meaning is not intuitive when reading code so I created both aliases for you to choose from.
|
|
77
|
+
# NOTE: Overkill? Maybe.
|
|
78
|
+
aka = alias = aliases
|
|
79
|
+
|
|
80
|
+
# alias for backward-compatability, will be removed eventually, probably in 0.1.0
|
|
81
|
+
ASyncBase = ASyncGenericBase
|
|
82
|
+
|
|
83
|
+
__all__ = [
|
|
84
|
+
# modules
|
|
85
|
+
"exceptions",
|
|
86
|
+
"iter",
|
|
87
|
+
"task",
|
|
88
|
+
# builtins
|
|
89
|
+
"sorted",
|
|
90
|
+
"filter",
|
|
91
|
+
# asyncio
|
|
92
|
+
"create_task",
|
|
93
|
+
"gather",
|
|
94
|
+
"cgather",
|
|
95
|
+
"igather",
|
|
96
|
+
"as_completed",
|
|
97
|
+
# functions
|
|
98
|
+
"a_sync",
|
|
99
|
+
"all",
|
|
100
|
+
"any",
|
|
101
|
+
"as_yielded",
|
|
102
|
+
"map",
|
|
103
|
+
# classes
|
|
104
|
+
"ASyncIterable",
|
|
105
|
+
"ASyncIterator",
|
|
106
|
+
"ASyncGenericBase",
|
|
107
|
+
"ASyncGenericSingleton",
|
|
108
|
+
"TaskMapping",
|
|
109
|
+
# property
|
|
110
|
+
"cached_property",
|
|
111
|
+
"property",
|
|
112
|
+
"ASyncPropertyDescriptor",
|
|
113
|
+
"ASyncCachedPropertyDescriptor",
|
|
114
|
+
# semaphores
|
|
115
|
+
"Semaphore",
|
|
116
|
+
"PrioritySemaphore",
|
|
117
|
+
"ThreadsafeSemaphore",
|
|
118
|
+
# queues
|
|
119
|
+
"Queue",
|
|
120
|
+
"ProcessingQueue",
|
|
121
|
+
"SmartProcessingQueue",
|
|
122
|
+
# locks
|
|
123
|
+
"CounterLock",
|
|
124
|
+
"Event",
|
|
125
|
+
# executors
|
|
126
|
+
"AsyncThreadPoolExecutor",
|
|
127
|
+
"PruningThreadPoolExecutor",
|
|
128
|
+
"AsyncProcessPoolExecutor",
|
|
129
|
+
# executor aliases
|
|
130
|
+
"ThreadPoolExecutor",
|
|
131
|
+
"ProcessPoolExecutor",
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _patch_async_property() -> None:
|
|
136
|
+
import async_property.base as base
|
|
137
|
+
import async_property.cached as cached
|
|
138
|
+
from a_sync.async_property.proxy import AwaitableOnly, AwaitableProxy
|
|
139
|
+
|
|
140
|
+
base.AwaitableOnly = AwaitableOnly
|
|
141
|
+
cached.AwaitableOnly = AwaitableOnly
|
|
142
|
+
cached.AwaitableProxy = AwaitableProxy
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
_patch_async_property()
|