ez-a-sync 0.24.9__tar.gz → 0.24.10__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 (170) hide show
  1. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/PKG-INFO +1 -1
  2. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/__init__.py +9 -0
  3. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/counter.pyi +1 -1
  4. ez_a_sync-0.24.9/a_sync/task.pyx → ez_a_sync-0.24.10/a_sync/task.py +71 -122
  5. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/ez_a_sync.egg-info/PKG-INFO +1 -1
  6. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/ez_a_sync.egg-info/SOURCES.txt +1 -3
  7. ez_a_sync-0.24.9/a_sync/task.c +0 -48953
  8. ez_a_sync-0.24.9/a_sync/task.pyi +0 -203
  9. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.coverage +0 -0
  10. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.github/workflows/black.yaml +0 -0
  11. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.github/workflows/codeql.yaml +0 -0
  12. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.github/workflows/docs.yaml +0 -0
  13. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.github/workflows/mypy.yaml +0 -0
  14. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.github/workflows/pytest.yaml +0 -0
  15. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.github/workflows/release.yaml +0 -0
  16. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.gitignore +0 -0
  17. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/.sourcery.yaml +0 -0
  18. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/LICENSE.txt +0 -0
  19. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/MANIFEST.in +0 -0
  20. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/Makefile +0 -0
  21. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/README.md +0 -0
  22. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/TODO +0 -0
  23. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/ENVIRONMENT_VARIABLES.py +0 -0
  24. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/__init__.pxd +0 -0
  25. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/__init__.py +0 -0
  26. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/_smart.py +0 -0
  27. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/_typing.py +0 -0
  28. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/__init__.py +0 -0
  29. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_descriptor.py +0 -0
  30. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_flags.c +0 -0
  31. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_flags.pxd +0 -0
  32. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_flags.pyx +0 -0
  33. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_helpers.c +0 -0
  34. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_helpers.pxd +0 -0
  35. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_helpers.pyi +0 -0
  36. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_helpers.pyx +0 -0
  37. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_kwargs.c +0 -0
  38. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_kwargs.pxd +0 -0
  39. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_kwargs.pyx +0 -0
  40. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/_meta.py +0 -0
  41. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/abstract.c +0 -0
  42. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/abstract.pyi +0 -0
  43. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/abstract.pyx +0 -0
  44. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/base.c +0 -0
  45. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/base.pyi +0 -0
  46. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/base.pyx +0 -0
  47. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/config.py +0 -0
  48. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/decorator.py +0 -0
  49. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/flags.py +0 -0
  50. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/function.c +0 -0
  51. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/function.pyi +0 -0
  52. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/function.pyx +0 -0
  53. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/method.c +0 -0
  54. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/method.pxd +0 -0
  55. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/method.pyi +0 -0
  56. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/method.pyx +0 -0
  57. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/__init__.py +0 -0
  58. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/cache/__init__.py +0 -0
  59. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/cache/memory.py +0 -0
  60. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/limiter.py +0 -0
  61. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/manager.c +0 -0
  62. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/manager.pyi +0 -0
  63. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/manager.pyx +0 -0
  64. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/modifiers/semaphores.py +0 -0
  65. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/property.c +0 -0
  66. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/property.pyi +0 -0
  67. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/property.pyx +0 -0
  68. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/a_sync/singleton.py +0 -0
  69. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/aliases.py +0 -0
  70. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/__init__.py +0 -0
  71. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/as_completed.c +0 -0
  72. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/as_completed.pxd +0 -0
  73. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/as_completed.pyi +0 -0
  74. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/as_completed.pyx +0 -0
  75. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/create_task.c +0 -0
  76. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/create_task.pxd +0 -0
  77. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/create_task.pyi +0 -0
  78. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/create_task.pyx +0 -0
  79. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/gather.c +0 -0
  80. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/gather.pyi +0 -0
  81. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/asyncio/gather.pyx +0 -0
  82. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/exceptions.py +0 -0
  83. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/executor.py +0 -0
  84. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/future.py +0 -0
  85. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/iter.c +0 -0
  86. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/iter.pyi +0 -0
  87. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/iter.pyx +0 -0
  88. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/__init__.pxd +0 -0
  89. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/__init__.py +0 -0
  90. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_debug.c +0 -0
  91. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_debug.pxd +0 -0
  92. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_debug.pyi +0 -0
  93. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_debug.pyx +0 -0
  94. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_loggable.c +0 -0
  95. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_loggable.pxd +0 -0
  96. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_loggable.pyi +0 -0
  97. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/_loggable.pyx +0 -0
  98. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/__init__.pxd +0 -0
  99. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/counter.c +0 -0
  100. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/counter.pxd +0 -0
  101. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/counter.pyx +0 -0
  102. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/event.c +0 -0
  103. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/event.pxd +0 -0
  104. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/event.pyi +0 -0
  105. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/event.pyx +0 -0
  106. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/prio_semaphore.c +0 -0
  107. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/prio_semaphore.pxd +0 -0
  108. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/prio_semaphore.pyi +0 -0
  109. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/prio_semaphore.pyx +0 -0
  110. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/semaphore.c +0 -0
  111. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/semaphore.pxd +0 -0
  112. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/semaphore.pyi +0 -0
  113. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/locks/semaphore.pyx +0 -0
  114. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/primitives/queue.py +0 -0
  115. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/py.typed +0 -0
  116. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/sphinx/__init__.py +0 -0
  117. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/sphinx/ext.py +0 -0
  118. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/utils/__init__.py +0 -0
  119. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/a_sync/utils/iterators.py +0 -0
  120. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/Makefile +0 -0
  121. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/alabaster.css +0 -0
  122. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/basic.css +0 -0
  123. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/custom.css +0 -0
  124. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/doctools.js +0 -0
  125. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/documentation_options.js +0 -0
  126. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/file.png +0 -0
  127. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/language_data.js +0 -0
  128. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/minus.png +0 -0
  129. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/plus.png +0 -0
  130. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/pygments.css +0 -0
  131. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/searchtools.js +0 -0
  132. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/_build/html/_static/sphinx_highlight.js +0 -0
  133. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/conf.py +0 -0
  134. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/index.rst +0 -0
  135. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/docs/make.bat +0 -0
  136. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/ez_a_sync.egg-info/dependency_links.txt +0 -0
  137. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/ez_a_sync.egg-info/not-zip-safe +0 -0
  138. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/ez_a_sync.egg-info/requires.txt +0 -0
  139. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/ez_a_sync.egg-info/top_level.txt +0 -0
  140. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/pyproject.yaml +0 -0
  141. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/requirements-dev.txt +0 -0
  142. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/requirements.txt +0 -0
  143. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/setup.cfg +0 -0
  144. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/setup.py +0 -0
  145. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/__init__.py +0 -0
  146. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/asyncio/test_as_completed.py +0 -0
  147. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/asyncio/test_create_task.py +0 -0
  148. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/asyncio/test_gather.py +0 -0
  149. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/conftest.py +0 -0
  150. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/executor.py +0 -0
  151. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/fixtures.py +0 -0
  152. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/primitives/test_event.py +0 -0
  153. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/primitives/test_prio_semaphore.py +0 -0
  154. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/primitives/test_queue.py +0 -0
  155. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/primitives/test_semaphore.py +0 -0
  156. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_abstract.py +0 -0
  157. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_base.py +0 -0
  158. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_cache.py +0 -0
  159. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_counter.py +0 -0
  160. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_decorator.py +0 -0
  161. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_event.py +0 -0
  162. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_executor.py +0 -0
  163. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_future.py +0 -0
  164. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_helpers.py +0 -0
  165. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_iter.py +0 -0
  166. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_limiter.py +0 -0
  167. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_meta.py +0 -0
  168. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_modified.py +0 -0
  169. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_singleton.py +0 -0
  170. {ez_a_sync-0.24.9 → ez_a_sync-0.24.10}/tests/test_task.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ez-a-sync
3
- Version: 0.24.9
3
+ Version: 0.24.10
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
@@ -6,3 +6,12 @@ from a_sync.primitives.locks.semaphore import (
6
6
  Semaphore,
7
7
  ThreadsafeSemaphore,
8
8
  )
9
+
10
+ __all__ = [
11
+ "Event",
12
+ "Semaphore",
13
+ "PrioritySemaphore",
14
+ "CounterLock",
15
+ "ThreadsafeSemaphore",
16
+ "DummySemaphore",
17
+ ]
@@ -1,6 +1,6 @@
1
1
  from _typeshed import Incomplete
2
2
  from a_sync.primitives._debug import _DebugDaemonMixin
3
- from a_sync.primitives.locks.event import Event as Event
3
+ from a_sync.primitives.locks import Event
4
4
  from typing import Iterable, Optional
5
5
 
6
6
  class CounterLock(_DebugDaemonMixin):
@@ -15,9 +15,11 @@ import inspect
15
15
  import logging
16
16
  import weakref
17
17
 
18
+ import a_sync.asyncio
18
19
  from a_sync import exceptions
19
20
  from a_sync._typing import *
20
- from a_sync.a_sync._kwargs cimport get_flag_name
21
+ from a_sync.a_sync import _kwargs
22
+ from a_sync.a_sync.base import ASyncGenericBase
21
23
  from a_sync.a_sync.function import ASyncFunction
22
24
  from a_sync.a_sync.method import (
23
25
  ASyncBoundMethod,
@@ -25,12 +27,10 @@ from a_sync.a_sync.method import (
25
27
  ASyncMethodDescriptorSyncDefault,
26
28
  )
27
29
  from a_sync.a_sync.property import _ASyncPropertyDescriptorBase
28
- from a_sync.asyncio import create_task, gather
29
- from a_sync.asyncio.as_completed cimport as_completed_mapping
30
30
  from a_sync.asyncio.gather import Excluder
31
31
  from a_sync.iter import ASyncIterator, ASyncGeneratorFunction, ASyncSorter
32
- from a_sync.primitives import Queue, ProcessingQueue
33
- from a_sync.primitives cimport Event
32
+ from a_sync.primitives.locks import Event
33
+ from a_sync.primitives.queue import Queue, ProcessingQueue
34
34
  from a_sync.utils.iterators import as_yielded, exhaust_iterator
35
35
 
36
36
 
@@ -68,7 +68,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
68
68
  See Also:
69
69
  - :class:`asyncio.Task`
70
70
  - :func:`asyncio.create_task`
71
- - :func:`create_task`
71
+ - :func:`a_sync.asyncio.create_task`
72
72
  """
73
73
 
74
74
  concurrency: Optional[int] = None
@@ -128,7 +128,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
128
128
 
129
129
  task_map = TaskMapping(process_item, [1, 2, 3], concurrency=2)
130
130
  """
131
- cdef Event _next
132
131
 
133
132
  if concurrency:
134
133
  self.concurrency = concurrency
@@ -145,7 +144,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
145
144
 
146
145
  if isinstance(
147
146
  wrapped_func, ASyncMethodDescriptor
148
- ) and not get_flag_name(wrapped_func_kwargs):
147
+ ) and not _kwargs.get_flag_name(wrapped_func_kwargs):
149
148
  wrapped_func_kwargs["sync"] = False
150
149
  if wrapped_func_kwargs:
151
150
  self._wrapped_func_kwargs = wrapped_func_kwargs
@@ -154,11 +153,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
154
153
  self._name = name
155
154
 
156
155
  if iterables:
157
- _next = Event(name="{} `_next`".format(self))
158
-
159
- # NOTE self._next will be a python object when retrieved for __aiter__
160
- # but _next is still a c object for _wrapped_set_next
161
- self._next = _next
156
+ self._next = Event(name=f"{self} `_next`")
162
157
 
163
158
  @functools.wraps(wrapped_func)
164
159
  async def _wrapped_set_next(
@@ -167,7 +162,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
167
162
  try:
168
163
  return await wrapped_func(*args, **kwargs)
169
164
  except exceptions.SyncModeInAsyncContextError as e:
170
- e.args = *e.args, "wrapped:{}".format(self.__wrapped__)
165
+ e.args = *e.args, f"wrapped:{self.__wrapped__}"
171
166
  raise
172
167
  except TypeError as e:
173
168
  if __a_sync_recursion > 2 or not (
@@ -199,8 +194,8 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
199
194
  else e2.with_traceback(e2.__traceback__)
200
195
  )
201
196
  finally:
202
- _next.c_set()
203
- _next.c_clear()
197
+ self._next.set()
198
+ self._next.clear()
204
199
 
205
200
  self._wrapped_func = _wrapped_set_next
206
201
  init_loader_queue: Queue[Tuple[K, "asyncio.Future[V]"]] = Queue()
@@ -213,13 +208,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
213
208
  self._init_loader_next = init_loader_queue.get_all
214
209
 
215
210
  def __repr__(self) -> str:
216
- return "<{} for {} kwargs={} tasks={} at {}>".format(
217
- type(self).__name__,
218
- self._wrapped_func,
219
- self._wrapped_func_kwargs,
220
- len(self),
221
- hex(id(self)),
222
- )
211
+ return f"<{type(self).__name__} for {self._wrapped_func} kwargs={self._wrapped_func_kwargs} tasks={len(self)} at {hex(id(self))}>"
223
212
 
224
213
  def __hash__(self) -> int:
225
214
  return id(self)
@@ -228,7 +217,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
228
217
  raise NotImplementedError("You cannot manually set items in a TaskMapping")
229
218
 
230
219
  def __getitem__(self, item: K) -> "asyncio.Task[V]":
231
- cdef object fut
232
220
  try:
233
221
  return super().__getitem__(item)
234
222
  except KeyError:
@@ -236,9 +224,9 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
236
224
  # NOTE: we use a queue instead of a Semaphore to reduce memory use for use cases involving many many tasks
237
225
  fut = self._queue.put_nowait(item)
238
226
  else:
239
- fut = create_task(
227
+ fut = a_sync.asyncio.create_task(
240
228
  coro=self._wrapped_func(item, **self._wrapped_func_kwargs),
241
- name="{}[{}]".format(self._name, item) if self._name else "{}".format(item),
229
+ name=f"{self._name}[{item}]" if self._name else f"{item}",
242
230
  )
243
231
  super().__setitem__(item, fut)
244
232
  return fut
@@ -249,18 +237,14 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
249
237
 
250
238
  async def __aiter__(self, pop: bool = False) -> AsyncIterator[Tuple[K, V]]:
251
239
  """Asynchronously iterate through all key-task pairs, yielding the key-result pair as each task completes."""
252
- cdef dict ready
253
- cdef object key, task, unyielded, value
254
- cdef Event next = self._next
255
-
256
- _if_pop_check_destroyed(self, pop)
240
+ self._if_pop_check_destroyed(pop)
257
241
 
258
242
  # if you inited the TaskMapping with some iterators, we will load those
259
- cdef set yielded = set()
243
+ yielded = set()
260
244
  try:
261
245
  if self._init_loader is None:
262
246
  # if you didn't init the TaskMapping with iterators and you didn't start any tasks manually, we should fail
263
- _raise_if_empty(mapping=self, msg="")
247
+ self._raise_if_empty()
264
248
  else:
265
249
  while not self._init_loader.done():
266
250
  await self._wait_for_next_key()
@@ -277,37 +261,27 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
277
261
  yield key, await task
278
262
  yielded.add(key)
279
263
  else:
280
- await next.c_wait()
264
+ await self._next.wait()
281
265
  # loader is already done by this point, but we need to check for exceptions
282
266
  await self._init_loader
283
267
  # if there are any tasks that still need to complete, we need to await them and yield them
284
268
  if unyielded := {key: self[key] for key in self if key not in yielded}:
285
269
  if pop:
286
- async for key, value in as_completed_mapping(
287
- mapping=unyielded,
288
- timeout=0,
289
- return_exceptions=False,
290
- aiter=True,
291
- tqdm=False,
292
- tqdm_kwargs={},
270
+ async for key, value in a_sync.asyncio.as_completed(
271
+ unyielded, aiter=True
293
272
  ):
294
273
  self.pop(key)
295
274
  yield key, value
296
275
  else:
297
- async for key, value in as_completed_mapping(
298
- mapping=unyielded,
299
- timeout=0,
300
- return_exceptions=False,
301
- aiter=True,
302
- tqdm=False,
303
- tqdm_kwargs={}
276
+ async for key, value in a_sync.asyncio.as_completed(
277
+ unyielded, aiter=True
304
278
  ):
305
279
  yield key, value
306
280
  finally:
307
281
  await self._if_pop_clear(pop)
308
282
 
309
283
  def __delitem__(self, item: K) -> None:
310
- cdef object task_or_fut = dict.__getitem__(self, item)
284
+ task_or_fut = dict.__getitem__(self, item)
311
285
  if not task_or_fut.done():
312
286
  task_or_fut.cancel()
313
287
  super().__delitem__(item)
@@ -352,8 +326,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
352
326
  async for key, result in task_map.map([1, 2, 3]):
353
327
  print(f"Processed {key}: {result}")
354
328
  """
355
- cdef object init_loader, key, value, _
356
- _if_pop_check_destroyed(self, pop)
329
+ self._if_pop_check_destroyed(pop)
357
330
 
358
331
  # make sure the init loader is started if needed
359
332
  init_loader = self._init_loader
@@ -364,8 +337,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
364
337
 
365
338
  try:
366
339
  if iterables:
367
- if self:
368
- raise exceptions.MappingNotEmptyError(self)
340
+ self._raise_if_not_empty()
369
341
  try:
370
342
  async for _ in self._tasks_for_iterables(*iterables):
371
343
  async for key, value in self.yield_completed(pop=pop):
@@ -383,31 +355,20 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
383
355
  await init_loader
384
356
 
385
357
  else:
386
- _raise_if_empty(
387
- mapping=self,
388
- msg="You must either initialize your TaskMapping with an iterable(s) or provide them during your call to map",
358
+ self._raise_if_empty(
359
+ "You must either initialize your TaskMapping with an iterable(s) or provide them during your call to map"
389
360
  )
390
361
 
391
362
  if self:
392
363
  if pop:
393
- async for key, value in as_completed_mapping(
394
- mapping=self,
395
- timeout=0,
396
- return_exceptions=False,
397
- aiter=True,
398
- tqdm=False,
399
- tqdm_kwargs={},
364
+ async for key, value in a_sync.asyncio.as_completed(
365
+ self, aiter=True
400
366
  ):
401
367
  self.pop(key)
402
368
  yield _yield(key, value, yields)
403
369
  else:
404
- async for key, value in as_completed_mapping(
405
- mapping=self,
406
- timeout=0,
407
- return_exceptions=False,
408
- aiter=True,
409
- tqdm=False,
410
- tqdm_kwargs={},
370
+ async for key, value in a_sync.asyncio.as_completed(
371
+ self, aiter=True
411
372
  ):
412
373
  yield _yield(key, value, yields)
413
374
  finally:
@@ -415,7 +376,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
415
376
 
416
377
  @ASyncMethodDescriptorSyncDefault
417
378
  async def all(self, pop: bool = True) -> bool:
418
- cdef object key, result
419
379
  try:
420
380
  async for key, result in self.__aiter__(pop=pop):
421
381
  if not bool(result):
@@ -428,7 +388,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
428
388
 
429
389
  @ASyncMethodDescriptorSyncDefault
430
390
  async def any(self, pop: bool = True) -> bool:
431
- cdef object key, result
432
391
  try:
433
392
  async for key, result in self.__aiter__(pop=pop):
434
393
  if bool(result):
@@ -441,7 +400,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
441
400
 
442
401
  @ASyncMethodDescriptorSyncDefault
443
402
  async def max(self, pop: bool = True) -> V:
444
- cdef object max, key, result
445
403
  max = None
446
404
  try:
447
405
  async for key, result in self.__aiter__(pop=pop):
@@ -460,7 +418,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
460
418
  @ASyncMethodDescriptorSyncDefault
461
419
  async def min(self, pop: bool = True) -> V:
462
420
  """Return the minimum result from the tasks in the mapping."""
463
- cdef object min, key, result
464
421
  min = None
465
422
  try:
466
423
  async for key, result in self.__aiter__(pop=pop):
@@ -479,7 +436,7 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
479
436
  @ASyncMethodDescriptorSyncDefault
480
437
  async def sum(self, pop: bool = False) -> V:
481
438
  """Return the sum of the results from the tasks in the mapping."""
482
- cdef object key, result, retval
439
+ retval = 0
483
440
  try:
484
441
  async for key, result in self.__aiter__(pop=pop):
485
442
  retval += result
@@ -507,7 +464,6 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
507
464
  async for key, result in task_map.yield_completed():
508
465
  print(f"Completed {key}: {result}")
509
466
  """
510
- cdef object k, task
511
467
  if pop:
512
468
  for k, task in dict(self).items():
513
469
  if task.done():
@@ -528,8 +484,8 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
528
484
  """Wait for all tasks to complete and return a dictionary of the results."""
529
485
  if self._init_loader:
530
486
  await self._init_loader
531
- _raise_if_empty(mapping=self, msg="")
532
- return await gather(
487
+ self._raise_if_empty()
488
+ return await a_sync.asyncio.gather(
533
489
  self,
534
490
  return_exceptions=return_exceptions,
535
491
  exclude_if=exclude_if,
@@ -569,16 +525,13 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
569
525
  *args: One key to pop.
570
526
  cancel: Whether to cancel the task when popping it.
571
527
  """
572
- cdef object fut_or_task = super().pop(*args)
528
+ fut_or_task = super().pop(*args)
573
529
  if cancel:
574
530
  fut_or_task.cancel()
575
531
  return fut_or_task
576
532
 
577
533
  def clear(self, cancel: bool = False) -> None:
578
534
  """# TODO write docs for this"""
579
- cdef tuple keys
580
- cdef object key
581
-
582
535
  if cancel and self._init_loader and not self._init_loader.done():
583
536
  logger.debug("cancelling %s", self._init_loader)
584
537
  # temporary, remove later
@@ -589,19 +542,16 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
589
542
  self._init_loader.cancel()
590
543
  if keys := tuple(self.keys()):
591
544
  logger.debug("popping remaining %s tasks", self)
592
- for key in keys:
593
- self.pop(key, cancel=cancel)
545
+ for k in keys:
546
+ self.pop(k, cancel=cancel)
594
547
 
595
548
  @functools.cached_property
596
549
  def _init_loader(self) -> Optional["asyncio.Task[None]"]:
597
- cdef str name
598
- cdef object task
599
-
600
550
  if self.__init_loader_coro:
601
551
  logger.debug("starting %s init loader", self)
602
- name = "{} init loader loading {} for {}".format(type(self).__name__, self.__iterables__, self)
552
+ name = f"{type(self).__name__} init loader loading {self.__iterables__} for {self}"
603
553
  try:
604
- task = create_task(
554
+ task = a_sync.asyncio.create_task(
605
555
  coro=self.__init_loader_coro, name=name
606
556
  )
607
557
  except RuntimeError as e:
@@ -611,20 +561,22 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
611
561
 
612
562
  @functools.cached_property
613
563
  def _queue(self) -> ProcessingQueue:
614
- return ProcessingQueue(
615
- functools.partial(self._wrapped_func, **self._wrapped_func_kwargs),
616
- self.concurrency,
617
- name=self._name,
618
- )
564
+ fn = functools.partial(self._wrapped_func, **self._wrapped_func_kwargs)
565
+ return ProcessingQueue(fn, self.concurrency, name=self._name)
566
+
567
+ def _raise_if_empty(self, msg: str = "") -> None:
568
+ if not self:
569
+ raise exceptions.MappingIsEmptyError(self, msg)
570
+
571
+ def _raise_if_not_empty(self) -> None:
572
+ if self:
573
+ raise exceptions.MappingNotEmptyError(self)
619
574
 
620
575
  @ASyncGeneratorFunction
621
576
  async def _tasks_for_iterables(
622
577
  self, *iterables: AnyIterableOrAwaitableIterable[K]
623
578
  ) -> AsyncIterator[Tuple[K, "asyncio.Task[V]"]]:
624
579
  """Ensure tasks are running for each key in the provided iterables."""
625
- cdef object iterable, key
626
- cdef list containers, remaining
627
-
628
580
  # if we have any regular containers we can yield their contents right away
629
581
  containers = [
630
582
  iterable
@@ -649,6 +601,12 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
649
601
  "DEV: figure out how to handle this situation"
650
602
  ) from None
651
603
 
604
+ def _if_pop_check_destroyed(self, pop: bool) -> None:
605
+ if pop:
606
+ if self._destroyed:
607
+ raise RuntimeError(f"{self} has already been consumed")
608
+ self._destroyed = True
609
+
652
610
  async def _if_pop_clear(self, pop: bool) -> None:
653
611
  if pop:
654
612
  self._destroyed = True
@@ -662,12 +620,9 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
662
620
 
663
621
  async def _wait_for_next_key(self) -> None:
664
622
  # NOTE if `_init_loader` has an exception it will return first, otherwise `_init_loader_next` will return always
665
- cdef set done, pending
666
- cdef object task
667
-
668
623
  done, pending = await asyncio.wait(
669
624
  [
670
- create_task(
625
+ a_sync.asyncio.create_task(
671
626
  self._init_loader_next(), log_destroy_pending=False
672
627
  ),
673
628
  self._init_loader,
@@ -683,23 +638,18 @@ class TaskMapping(DefaultDict[K, "asyncio.Task[V]"], AsyncIterable[Tuple[K, V]])
683
638
  del self.__init_loader_coro
684
639
 
685
640
 
686
-
687
- cdef void _if_pop_check_destroyed(object mapping, bint pop):
688
- if pop:
689
- if mapping._destroyed:
690
- raise RuntimeError("{} has already been consumed".format(mapping))
691
- mapping._destroyed = True
692
-
693
-
694
- cdef void _raise_if_empty(object mapping, str msg):
695
- if not mapping:
696
- raise exceptions.MappingIsEmptyError(mapping, msg)
697
-
698
-
699
641
  class _NoRunningLoop(Exception): ...
700
642
 
701
643
 
702
- cdef object _yield(object key, object value, str yields):
644
+ @overload
645
+ def _yield(
646
+ key: K, value: V, yields: Literal["keys"]
647
+ ) -> K: ... # TODO write specific docs for this overload
648
+ @overload
649
+ def _yield(
650
+ key: K, value: V, yields: Literal["both"]
651
+ ) -> Tuple[K, V]: ... # TODO write specific docs for this overload
652
+ def _yield(key: K, value: V, yields: Literal["keys", "both"]) -> Union[K, Tuple[K, V]]:
703
653
  """
704
654
  Yield either the key, value, or both based on the 'yields' parameter.
705
655
 
@@ -715,7 +665,8 @@ cdef object _yield(object key, object value, str yields):
715
665
  return key, value
716
666
  elif yields == "keys":
717
667
  return key
718
- raise ValueError("`yields` must be 'keys' or 'both'. You passed {}".format(yields))
668
+ else:
669
+ raise ValueError(f"`yields` must be 'keys' or 'both'. You passed {yields}")
719
670
 
720
671
 
721
672
  class _EmptySequenceError(ValueError): ...
@@ -778,7 +729,7 @@ _get_key: Callable[[Tuple[K, V]], K] = lambda k_and_v: k_and_v[0]
778
729
  _get_value: Callable[[Tuple[K, V]], V] = lambda k_and_v: k_and_v[1]
779
730
 
780
731
 
781
- class _TaskMappingView(Iterable[T], Generic[T, K, V]):
732
+ class _TaskMappingView(ASyncGenericBase, Iterable[T], Generic[T, K, V]):
782
733
  """
783
734
  Base class for TaskMapping views that provides common functionality.
784
735
  """
@@ -806,14 +757,12 @@ class _TaskMappingView(Iterable[T], Generic[T, K, V]):
806
757
  def __len__(self) -> int:
807
758
  return len(self.__view__)
808
759
 
809
- @ASyncIterator.wrap
810
760
  async def aiterbykeys(self, reverse: bool = False) -> ASyncIterator[T]:
811
761
  async for tup in ASyncSorter(
812
762
  self.__mapping__.items(pop=self._pop), key=_get_key, reverse=reverse
813
763
  ):
814
764
  yield self._get_from_item(tup)
815
765
 
816
- @ASyncIterator.wrap
817
766
  async def aiterbyvalues(self, reverse: bool = False) -> ASyncIterator[T]:
818
767
  async for tup in ASyncSorter(
819
768
  self.__mapping__.items(pop=self._pop), key=_get_value, reverse=reverse
@@ -834,7 +783,7 @@ class TaskMappingKeys(_TaskMappingView[K, K, V], Generic[K, V]):
834
783
  async def __aiter__(self) -> AsyncIterator[K]:
835
784
  # strongref
836
785
  mapping = self.__mapping__
837
- _if_pop_check_destroyed(mapping, self._pop)
786
+ mapping._if_pop_check_destroyed(self._pop)
838
787
  yielded = set()
839
788
  for key in self.__load_existing():
840
789
  yielded.add(key)
@@ -895,7 +844,7 @@ class TaskMappingItems(_TaskMappingView[Tuple[K, V], K, V], Generic[K, V]):
895
844
  async def __aiter__(self) -> AsyncIterator[Tuple[K, V]]:
896
845
  # strongref
897
846
  mapping = self.__mapping__
898
- _if_pop_check_destroyed(mapping, self._pop)
847
+ mapping._if_pop_check_destroyed(self._pop)
899
848
  if self._pop:
900
849
  async for key in mapping.keys():
901
850
  yield key, await mapping.pop(key)
@@ -914,7 +863,7 @@ class TaskMappingValues(_TaskMappingView[V, K, V], Generic[K, V]):
914
863
  async def __aiter__(self) -> AsyncIterator[V]:
915
864
  # strongref
916
865
  mapping = self.__mapping__
917
- _if_pop_check_destroyed(mapping, self._pop)
866
+ mapping._if_pop_check_destroyed(self._pop)
918
867
  if self._pop:
919
868
  async for key in mapping.keys():
920
869
  yield await mapping.pop(key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ez-a-sync
3
- Version: 0.24.9
3
+ Version: 0.24.10
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
@@ -30,9 +30,7 @@ a_sync/iter.c
30
30
  a_sync/iter.pyi
31
31
  a_sync/iter.pyx
32
32
  a_sync/py.typed
33
- a_sync/task.c
34
- a_sync/task.pyi
35
- a_sync/task.pyx
33
+ a_sync/task.py
36
34
  a_sync/a_sync/__init__.py
37
35
  a_sync/a_sync/_descriptor.py
38
36
  a_sync/a_sync/_flags.c