ez-a-sync 0.22.14__tar.gz → 0.22.16__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.

Files changed (150) hide show
  1. ez_a_sync-0.22.16/.github/workflows/black.yaml +45 -0
  2. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.github/workflows/mypy.yaml +1 -1
  3. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/PKG-INFO +1 -1
  4. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/README.md +135 -0
  5. ez_a_sync-0.22.16/a_sync/ENVIRONMENT_VARIABLES.py +44 -0
  6. ez_a_sync-0.22.16/a_sync/__init__.py +125 -0
  7. ez_a_sync-0.22.16/a_sync/_smart.py +393 -0
  8. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/_typing.py +112 -15
  9. ez_a_sync-0.22.16/a_sync/a_sync/__init__.py +53 -0
  10. ez_a_sync-0.22.16/a_sync/a_sync/_descriptor.py +429 -0
  11. ez_a_sync-0.22.16/a_sync/a_sync/_flags.py +128 -0
  12. ez_a_sync-0.22.16/a_sync/a_sync/_helpers.py +91 -0
  13. ez_a_sync-0.22.16/a_sync/a_sync/_kwargs.py +69 -0
  14. ez_a_sync-0.22.16/a_sync/a_sync/_meta.py +220 -0
  15. ez_a_sync-0.22.16/a_sync/a_sync/abstract.py +202 -0
  16. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/a_sync/base.py +34 -16
  17. ez_a_sync-0.22.16/a_sync/a_sync/config.py +144 -0
  18. ez_a_sync-0.22.16/a_sync/a_sync/decorator.py +559 -0
  19. ez_a_sync-0.22.16/a_sync/a_sync/function.py +1202 -0
  20. ez_a_sync-0.22.16/a_sync/a_sync/method.py +908 -0
  21. ez_a_sync-0.22.16/a_sync/a_sync/modifiers/__init__.py +99 -0
  22. ez_a_sync-0.22.16/a_sync/a_sync/modifiers/cache/__init__.py +159 -0
  23. ez_a_sync-0.22.16/a_sync/a_sync/modifiers/cache/memory.py +172 -0
  24. ez_a_sync-0.22.16/a_sync/a_sync/modifiers/limiter.py +134 -0
  25. ez_a_sync-0.22.16/a_sync/a_sync/modifiers/manager.py +215 -0
  26. ez_a_sync-0.22.16/a_sync/a_sync/modifiers/semaphores.py +175 -0
  27. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/a_sync/property.py +383 -82
  28. ez_a_sync-0.22.16/a_sync/a_sync/singleton.py +61 -0
  29. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/aliases.py +0 -1
  30. ez_a_sync-0.22.16/a_sync/asyncio/__init__.py +149 -0
  31. ez_a_sync-0.22.16/a_sync/asyncio/as_completed.py +279 -0
  32. ez_a_sync-0.22.16/a_sync/asyncio/create_task.py +152 -0
  33. ez_a_sync-0.22.16/a_sync/asyncio/gather.py +206 -0
  34. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/asyncio/utils.py +3 -3
  35. ez_a_sync-0.22.16/a_sync/exceptions.py +429 -0
  36. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/executor.py +164 -69
  37. ez_a_sync-0.22.16/a_sync/future.py +1609 -0
  38. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/iter.py +173 -56
  39. ez_a_sync-0.22.16/a_sync/primitives/__init__.py +30 -0
  40. ez_a_sync-0.22.16/a_sync/primitives/_debug.py +136 -0
  41. ez_a_sync-0.22.16/a_sync/primitives/_loggable.py +69 -0
  42. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/primitives/locks/__init__.py +5 -2
  43. ez_a_sync-0.22.16/a_sync/primitives/locks/counter.py +213 -0
  44. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/primitives/locks/event.py +21 -7
  45. ez_a_sync-0.22.16/a_sync/primitives/locks/prio_semaphore.py +414 -0
  46. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/primitives/locks/semaphore.py +138 -89
  47. ez_a_sync-0.22.16/a_sync/primitives/queue.py +919 -0
  48. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/sphinx/__init__.py +0 -1
  49. ez_a_sync-0.22.16/a_sync/sphinx/ext.py +299 -0
  50. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/task.py +313 -112
  51. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/utils/__init__.py +12 -6
  52. ez_a_sync-0.22.16/a_sync/utils/iterators.py +282 -0
  53. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/conf.py +59 -47
  54. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/ez_a_sync.egg-info/PKG-INFO +1 -1
  55. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/ez_a_sync.egg-info/SOURCES.txt +2 -0
  56. ez_a_sync-0.22.16/pyproject.yaml +2 -0
  57. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/setup.py +7 -7
  58. ez_a_sync-0.22.16/tests/conftest.py +3 -0
  59. ez_a_sync-0.22.16/tests/executor.py +252 -0
  60. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/fixtures.py +61 -32
  61. ez_a_sync-0.22.16/tests/test_abstract.py +35 -0
  62. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_as_completed.py +54 -21
  63. ez_a_sync-0.22.16/tests/test_base.py +480 -0
  64. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_cache.py +31 -15
  65. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_decorator.py +54 -28
  66. ez_a_sync-0.22.16/tests/test_executor.py +58 -0
  67. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_future.py +45 -8
  68. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_gather.py +8 -2
  69. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_helpers.py +2 -0
  70. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_iter.py +55 -13
  71. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_limiter.py +5 -3
  72. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_meta.py +23 -9
  73. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_modified.py +4 -1
  74. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_semaphore.py +15 -8
  75. ez_a_sync-0.22.16/tests/test_singleton.py +37 -0
  76. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/test_task.py +162 -36
  77. ez_a_sync-0.22.14/a_sync/ENVIRONMENT_VARIABLES.py +0 -12
  78. ez_a_sync-0.22.14/a_sync/__init__.py +0 -84
  79. ez_a_sync-0.22.14/a_sync/_smart.py +0 -190
  80. ez_a_sync-0.22.14/a_sync/a_sync/__init__.py +0 -28
  81. ez_a_sync-0.22.14/a_sync/a_sync/_descriptor.py +0 -219
  82. ez_a_sync-0.22.14/a_sync/a_sync/_flags.py +0 -59
  83. ez_a_sync-0.22.14/a_sync/a_sync/_helpers.py +0 -58
  84. ez_a_sync-0.22.14/a_sync/a_sync/_kwargs.py +0 -44
  85. ez_a_sync-0.22.14/a_sync/a_sync/_meta.py +0 -99
  86. ez_a_sync-0.22.14/a_sync/a_sync/abstract.py +0 -80
  87. ez_a_sync-0.22.14/a_sync/a_sync/config.py +0 -73
  88. ez_a_sync-0.22.14/a_sync/a_sync/decorator.py +0 -257
  89. ez_a_sync-0.22.14/a_sync/a_sync/function.py +0 -640
  90. ez_a_sync-0.22.14/a_sync/a_sync/method.py +0 -581
  91. ez_a_sync-0.22.14/a_sync/a_sync/modifiers/__init__.py +0 -19
  92. ez_a_sync-0.22.14/a_sync/a_sync/modifiers/cache/__init__.py +0 -60
  93. ez_a_sync-0.22.14/a_sync/a_sync/modifiers/cache/memory.py +0 -62
  94. ez_a_sync-0.22.14/a_sync/a_sync/modifiers/limiter.py +0 -55
  95. ez_a_sync-0.22.14/a_sync/a_sync/modifiers/manager.py +0 -89
  96. ez_a_sync-0.22.14/a_sync/a_sync/modifiers/semaphores.py +0 -69
  97. ez_a_sync-0.22.14/a_sync/a_sync/singleton.py +0 -36
  98. ez_a_sync-0.22.14/a_sync/asyncio/__init__.py +0 -10
  99. ez_a_sync-0.22.14/a_sync/asyncio/as_completed.py +0 -145
  100. ez_a_sync-0.22.14/a_sync/asyncio/create_task.py +0 -102
  101. ez_a_sync-0.22.14/a_sync/asyncio/gather.py +0 -139
  102. ez_a_sync-0.22.14/a_sync/exceptions.py +0 -207
  103. ez_a_sync-0.22.14/a_sync/future.py +0 -550
  104. ez_a_sync-0.22.14/a_sync/primitives/__init__.py +0 -18
  105. ez_a_sync-0.22.14/a_sync/primitives/_debug.py +0 -82
  106. ez_a_sync-0.22.14/a_sync/primitives/_loggable.py +0 -38
  107. ez_a_sync-0.22.14/a_sync/primitives/locks/counter.py +0 -144
  108. ez_a_sync-0.22.14/a_sync/primitives/locks/prio_semaphore.py +0 -215
  109. ez_a_sync-0.22.14/a_sync/primitives/queue.py +0 -378
  110. ez_a_sync-0.22.14/a_sync/sphinx/ext.py +0 -189
  111. ez_a_sync-0.22.14/a_sync/utils/iterators.py +0 -162
  112. ez_a_sync-0.22.14/tests/conftest.py +0 -4
  113. ez_a_sync-0.22.14/tests/executor.py +0 -11
  114. ez_a_sync-0.22.14/tests/test_abstract.py +0 -17
  115. ez_a_sync-0.22.14/tests/test_base.py +0 -235
  116. ez_a_sync-0.22.14/tests/test_executor.py +0 -40
  117. ez_a_sync-0.22.14/tests/test_singleton.py +0 -20
  118. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.coverage +0 -0
  119. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.github/workflows/codeql.yaml +0 -0
  120. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.github/workflows/docs.yaml +0 -0
  121. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.github/workflows/pytest.yaml +0 -0
  122. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.github/workflows/release.yaml +0 -0
  123. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.gitignore +0 -0
  124. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/.sourcery.yaml +0 -0
  125. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/LICENSE.txt +0 -0
  126. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/Makefile +0 -0
  127. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/TODO +0 -0
  128. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/a_sync/py.typed +0 -0
  129. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/Makefile +0 -0
  130. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/alabaster.css +0 -0
  131. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/basic.css +0 -0
  132. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/custom.css +0 -0
  133. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/doctools.js +0 -0
  134. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/documentation_options.js +0 -0
  135. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/file.png +0 -0
  136. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/language_data.js +0 -0
  137. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/minus.png +0 -0
  138. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/plus.png +0 -0
  139. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/pygments.css +0 -0
  140. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/searchtools.js +0 -0
  141. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/_build/html/_static/sphinx_highlight.js +0 -0
  142. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/index.rst +0 -0
  143. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/docs/make.bat +0 -0
  144. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/ez_a_sync.egg-info/dependency_links.txt +0 -0
  145. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/ez_a_sync.egg-info/requires.txt +0 -0
  146. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/ez_a_sync.egg-info/top_level.txt +0 -0
  147. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/requirements-dev.txt +0 -0
  148. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/requirements.txt +0 -0
  149. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/setup.cfg +0 -0
  150. {ez_a_sync-0.22.14 → ez_a_sync-0.22.16}/tests/__init__.py +0 -0
@@ -0,0 +1,45 @@
1
+ name: Black Formatter
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ format:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v3
15
+ with:
16
+ ref: ${{ github.head_ref }} # Check out the PR branch
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v4
20
+ with:
21
+ python-version: '3.12'
22
+
23
+ - name: Install Black
24
+ run: pip install black
25
+
26
+ - name: Run Black
27
+ run: black .
28
+
29
+ - name: Check for changes
30
+ id: changes
31
+ run: |
32
+ if [[ -n $(git status --porcelain) ]]; then
33
+ echo "changes_detected=true" >> $GITHUB_ENV
34
+ else
35
+ echo "changes_detected=false" >> $GITHUB_ENV
36
+ fi
37
+
38
+ - name: Commit changes
39
+ if: env.changes_detected == 'true'
40
+ run: |
41
+ git config --local user.name "github-actions[bot]"
42
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
43
+ git add .
44
+ git commit -m "chore: \`black .\`"
45
+ git push
@@ -30,4 +30,4 @@ jobs:
30
30
  python -m pip install --upgrade pip
31
31
  pip install mypy types-requests
32
32
  - name: Run MyPy
33
- run: mypy ./a_sync --pretty --ignore-missing-imports --show-error-codes --show-error-context --enable-incomplete-feature=Unpack
33
+ run: mypy ./a_sync --pretty --ignore-missing-imports --show-error-codes --show-error-context --enable-incomplete-feature=Unpack --install-types --non-interactive
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ez-a-sync
3
- Version: 0.22.14
3
+ Version: 0.22.16
4
4
  Summary: A library that makes it easy to define objects that can be used for both sync and async use cases.
5
5
  Home-page: https://github.com/BobTheBuidler/a-sync
6
6
  Author: BobTheBuidler
@@ -13,12 +13,25 @@
13
13
  - [async modifiers](#async-modifiers)
14
14
  - [sync modifiers](#sync-modifiers)
15
15
  - [Default Modifiers](#default-modifiers)
16
+ - [Other Helpful Classes](#other-helpful-modules)
17
+ - [ASyncIterable](#asynciterable)
18
+ - [ASyncIterator](#asynciterator)
19
+ - [ASyncFilter](#asyncfilter)
20
+ - [ASyncSorter](#asyncsorter)
21
+ - [Other Helpful Modules](#other-helpful-modules)
22
+ - [future](#future)
23
+ - [ASyncFuture](#asyncfuture)
24
+ - [future decorator](#future-decorator)
25
+ - [asyncio](#asyncio)
16
26
 
17
27
  <!-- /TOC -->
18
28
  ## Introduction
19
29
 
20
30
  `ez-a-sync` is a Python library that enables developers to write both synchronous and asynchronous code without having to write redundant code. It provides a decorator `@a_sync()`, as well as a base class `ASyncGenericBase` which can be used to create classes that can be executed in both synchronous and asynchronous contexts.
21
31
 
32
+ It also contains implementations of various asyncio primitives with extra functionality, including queues and various types of locks.
33
+ \# TODO add links to various objects' docs
34
+
22
35
  ## Installation
23
36
 
24
37
  `ez-a-sync` can be installed via pip:
@@ -192,3 +205,125 @@ Instead of setting modifiers one by one in functions, you can set a default valu
192
205
  - `RAM_CACHE_TTL`
193
206
  - `RUNS_PER_MINUTE`
194
207
  - `SEMAPHORE`
208
+
209
+ ### Other Helpful Classes
210
+ #### ASyncIterable
211
+ The [ASyncIterable](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncIterable) class allows objects to be iterated over using either a standard `for` loop or an `async for` loop. This is particularly useful in scenarios where the mode of iteration needs to be flexible or is determined at runtime.
212
+
213
+ ```python
214
+ from a_sync import ASyncIterable
215
+
216
+ async_iterable = ASyncIterable(some_async_iterable)
217
+
218
+ # Asynchronous iteration
219
+ async for item in async_iterable:
220
+ ...
221
+
222
+ # Synchronous iteration
223
+ for item in async_iterable:
224
+ ...
225
+ ```
226
+
227
+ See the [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncIterable) for more information.
228
+
229
+ #### ASyncIterator
230
+
231
+ The [ASyncIterator](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncIterator) class provides a unified interface for iteration that can operate in both synchronous and asynchronous contexts. It allows the wrapping of asynchronous iterable objects or async generator functions.
232
+
233
+ ```python
234
+ from a_sync import ASyncIterator
235
+
236
+ async_iterator = ASyncIterator(some_async_iterator)
237
+
238
+ # Asynchronous iteration
239
+ async for item in async_iterator:
240
+ ...
241
+
242
+ # Synchronous iteration
243
+ for item in async_iterator:
244
+ ...
245
+ ```
246
+
247
+ See the [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncIterator) for more information.
248
+
249
+ #### ASyncFilter
250
+
251
+ The [ASyncFilter](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncFilter) class filters items of an async iterable based on a provided function. It can handle both synchronous and asynchronous filter functions.
252
+
253
+ ```python
254
+ from a_sync import ASyncFilter
255
+
256
+ async def is_even(x):
257
+ return x % 2 == 0
258
+
259
+ filtered_iterable = ASyncFilter(is_even, some_async_iterable)
260
+
261
+ # or use the alias
262
+ import a_sync
263
+
264
+ filtered_iterable = a_sync.filter(is_even, some_async_iterable)
265
+
266
+ # Asynchronous iteration
267
+ async for item in filtered_iterable:
268
+ ...
269
+
270
+ # Synchronous iteration
271
+ for item in filtered_iterable:
272
+ ...
273
+ ```
274
+
275
+ See the [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncFilter) for more information.
276
+
277
+ #### ASyncSorter
278
+
279
+ The [ASyncSorter](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncSorter) class sorts items of an async iterable based on a provided key function. It supports both synchronous and asynchronous key functions.
280
+
281
+ ```python
282
+ from a_sync import ASyncSorter
283
+
284
+ sorted_iterable = ASyncSorter(some_async_iterable, key=lambda x: x.value)
285
+
286
+ # or use the alias
287
+ import a_sync
288
+
289
+ sorted_iterable = a_sync.sort(some_async_iterable, key=lambda x: x.value)
290
+
291
+ # Asynchronous iteration
292
+ async for item in sorted_iterable:
293
+ ...
294
+
295
+ # Synchronous iteration
296
+ for item in sorted_iterable:
297
+ ...
298
+ ```
299
+
300
+ See the [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.ASyncSorter) for more information.
301
+
302
+ ## Other Helpful Modules
303
+ The stuff here is unrelated to the main purpose of ez-a-sync, but cool and useful nonetheless
304
+
305
+ ### asyncio
306
+
307
+ The `ez-a-sync` library extends the functionality of Python's `asyncio` module with additional utilities to simplify asynchronous programming.
308
+
309
+ - **as_completed**: This function allows you to iterate over awaitables as they complete, similar to `asyncio.as_completed`. It supports both synchronous and asynchronous iteration. [Learn more about `as_completed`](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.asyncio.as_completed).
310
+
311
+ - **gather**: A utility to run multiple asynchronous operations concurrently and wait for all of them to complete. It is similar to `asyncio.gather` but integrates seamlessly with the `ez-a-sync` library. [Learn more about `gather`](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.asyncio.gather).
312
+
313
+ - **create_task**: A function to create a new task from a coroutine, similar to `asyncio.create_task`, but with additional features provided by `ez-a-sync`. [Learn more about `create_task`](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.asyncio.create_task).
314
+
315
+ - **as_completed**: This function allows you to iterate over awaitables as they complete, similar to `asyncio.as_completed`. It supports both synchronous and asynchronous iteration. [Learn more about `as_completed`](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.asyncio.as_completed).
316
+
317
+ These utilities enhance the standard `asyncio` module, providing more flexibility and control over asynchronous operations. For detailed documentation and examples, please refer to the [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.asyncio)
318
+
319
+ ### future
320
+ The future module is something totally different.
321
+ TODO: short explainer of module value prop and use case
322
+
323
+ #### ASyncFuture
324
+ [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.future.ASyncFuture)
325
+ TODO: short explainers on ASyncFuture class
326
+
327
+ #### future decorator
328
+ [documentation](#https://bobthebuidler.github.io/ez-a-sync/source/a_sync.html#a_sync.future.future)
329
+ TODO: short explainers on future fn
@@ -0,0 +1,44 @@
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(
24
+ "DEBUG_MODE", bool, default=bool(DEBUG_CLASS_NAME), verbose=False
25
+ )
26
+ """bool: Enables debug mode on all classes.
27
+
28
+ Set this environment variable to `True` to enable debug mode on all classes.
29
+ If `DEBUG_CLASS_NAME` is set to a truthy value other than an empty string,
30
+ `DEBUG_MODE` will default to `True`.
31
+
32
+ Examples:
33
+ To enable debug mode globally, set the environment variable:
34
+
35
+ .. code-block:: bash
36
+
37
+ export EZASYNC_DEBUG_MODE=True
38
+
39
+ If you have set `DEBUG_CLASS_NAME` to a specific class, `DEBUG_MODE` will
40
+ automatically be `True` unless `DEBUG_CLASS_NAME` is an empty string.
41
+
42
+ See Also:
43
+ :func:`DEBUG_CLASS_NAME` for debugging a specific class.
44
+ """
@@ -0,0 +1,125 @@
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:`~aliases`, :mod:`~exceptions`, :mod:`~iter`, :mod:`~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:`~ASyncFilter`, :class:`~ASyncSorter`, :class:`~ASyncIterable`, :class:`~ASyncIterator` for async iteration.
17
+ - Utilities: :func:`~all`, :func:`~any`, :func:`~as_yielded`, :func:`~exhaust_iterator`, :func:`~exhaust_iterators` for async utilities.
18
+ - :func:`~apply_semaphore`: Function to apply semaphores to coroutines.
19
+
20
+ Alias for backward compatibility:
21
+ - :class:`~ASyncBase` is an alias for :class:`~ASyncGenericBase`, which will be removed eventually, probably in version 0.1.0.
22
+
23
+ Examples:
24
+ Using the `@a_sync` decorator:
25
+ >>> from a_sync import a_sync
26
+ >>> @a_sync
27
+ ... async def my_function():
28
+ ... return "Hello, World!"
29
+ >>> result = await my_function()
30
+ >>> print(result)
31
+
32
+ Using `ASyncGenericBase` for dual-context classes:
33
+ >>> from a_sync import ASyncGenericBase
34
+ >>> class MyClass(ASyncGenericBase):
35
+ ... async def my_method(self):
36
+ ... return "Hello from MyClass"
37
+ >>> obj = MyClass()
38
+ >>> result = await obj.my_method()
39
+ >>> print(result)
40
+
41
+ See Also:
42
+ - :mod:`a_sync.a_sync`: Contains the core classes and decorators.
43
+ - :mod:`a_sync.asyncio`: Provides enhanced asyncio functions.
44
+ - :mod:`a_sync.primitives`: Includes modified versions of standard asyncio primitives.
45
+ """
46
+
47
+ from a_sync import aliases, exceptions, iter, task
48
+ from a_sync.a_sync import ASyncGenericBase, ASyncGenericSingleton, a_sync
49
+ from a_sync.a_sync.modifiers.semaphores import apply_semaphore
50
+ from a_sync.a_sync.property import (
51
+ ASyncCachedPropertyDescriptor,
52
+ ASyncPropertyDescriptor,
53
+ cached_property,
54
+ property,
55
+ )
56
+ from a_sync.asyncio import as_completed, create_task, gather
57
+ from a_sync.executor import *
58
+ from a_sync.executor import AsyncThreadPoolExecutor as ThreadPoolExecutor
59
+ from a_sync.executor import AsyncProcessPoolExecutor as ProcessPoolExecutor
60
+ from a_sync.future import ASyncFuture, future # type: ignore [attr-defined]
61
+ from a_sync.iter import ASyncFilter as filter
62
+ from a_sync.iter import ASyncSorter as sorted
63
+ from a_sync.iter import ASyncIterable, ASyncIterator
64
+ from a_sync.primitives import *
65
+ from a_sync.task import TaskMapping as map
66
+ from a_sync.task import TaskMapping, create_task
67
+ from a_sync.utils import all, any, as_yielded
68
+
69
+ # I alias the aliases for your convenience.
70
+ # I prefer "aka" but its meaning is not intuitive when reading code so I created both aliases for you to choose from.
71
+ # NOTE: Overkill? Maybe.
72
+ aka = alias = aliases
73
+
74
+ # alias for backward-compatability, will be removed eventually, probably in 0.1.0
75
+ ASyncBase = ASyncGenericBase
76
+
77
+ __all__ = [
78
+ # modules
79
+ "exceptions",
80
+ "iter",
81
+ "task",
82
+ # builtins
83
+ "sorted",
84
+ "filter",
85
+ # asyncio
86
+ "create_task",
87
+ "gather",
88
+ "as_completed",
89
+ # functions
90
+ "a_sync",
91
+ "all",
92
+ "any",
93
+ "as_yielded",
94
+ "exhaust_iterator",
95
+ "exhaust_iterators",
96
+ "map",
97
+ # classes
98
+ "ASyncIterable",
99
+ "ASyncIterator",
100
+ "ASyncGenericSingleton",
101
+ "TaskMapping",
102
+ # property
103
+ "cached_property",
104
+ "property",
105
+ "ASyncPropertyDescriptor",
106
+ "ASyncCachedPropertyDescriptor",
107
+ # semaphores
108
+ "Semaphore",
109
+ "PrioritySemaphore",
110
+ "ThreadsafeSemaphore",
111
+ # queues
112
+ "Queue",
113
+ "ProcessingQueue",
114
+ "SmartProcessingQueue",
115
+ # locks
116
+ "CounterLock",
117
+ "Event",
118
+ # executors
119
+ "AsyncThreadPoolExecutor",
120
+ "PruningThreadPoolExecutor",
121
+ "AsyncProcessPoolExecutor",
122
+ # executor aliases
123
+ "ThreadPoolExecutor",
124
+ "ProcessPoolExecutor",
125
+ ]