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.

Files changed (177) hide show
  1. a_sync/ENVIRONMENT_VARIABLES.py +42 -0
  2. a_sync/__init__.pxd +2 -0
  3. a_sync/__init__.py +145 -0
  4. a_sync/_smart.c +22803 -0
  5. a_sync/_smart.cp310-win_amd64.pyd +0 -0
  6. a_sync/_smart.pxd +2 -0
  7. a_sync/_smart.pyi +202 -0
  8. a_sync/_smart.pyx +674 -0
  9. a_sync/_typing.py +258 -0
  10. a_sync/a_sync/__init__.py +60 -0
  11. a_sync/a_sync/_descriptor.c +20528 -0
  12. a_sync/a_sync/_descriptor.cp310-win_amd64.pyd +0 -0
  13. a_sync/a_sync/_descriptor.pyi +33 -0
  14. a_sync/a_sync/_descriptor.pyx +422 -0
  15. a_sync/a_sync/_flags.c +6074 -0
  16. a_sync/a_sync/_flags.cp310-win_amd64.pyd +0 -0
  17. a_sync/a_sync/_flags.pxd +3 -0
  18. a_sync/a_sync/_flags.pyx +92 -0
  19. a_sync/a_sync/_helpers.c +14521 -0
  20. a_sync/a_sync/_helpers.cp310-win_amd64.pyd +0 -0
  21. a_sync/a_sync/_helpers.pxd +3 -0
  22. a_sync/a_sync/_helpers.pyi +10 -0
  23. a_sync/a_sync/_helpers.pyx +167 -0
  24. a_sync/a_sync/_kwargs.c +12194 -0
  25. a_sync/a_sync/_kwargs.cp310-win_amd64.pyd +0 -0
  26. a_sync/a_sync/_kwargs.pxd +2 -0
  27. a_sync/a_sync/_kwargs.pyx +64 -0
  28. a_sync/a_sync/_meta.py +210 -0
  29. a_sync/a_sync/abstract.c +12411 -0
  30. a_sync/a_sync/abstract.cp310-win_amd64.pyd +0 -0
  31. a_sync/a_sync/abstract.pyi +141 -0
  32. a_sync/a_sync/abstract.pyx +221 -0
  33. a_sync/a_sync/base.c +14932 -0
  34. a_sync/a_sync/base.cp310-win_amd64.pyd +0 -0
  35. a_sync/a_sync/base.pyi +60 -0
  36. a_sync/a_sync/base.pyx +271 -0
  37. a_sync/a_sync/config.py +168 -0
  38. a_sync/a_sync/decorator.py +651 -0
  39. a_sync/a_sync/flags.c +5272 -0
  40. a_sync/a_sync/flags.cp310-win_amd64.pyd +0 -0
  41. a_sync/a_sync/flags.pxd +72 -0
  42. a_sync/a_sync/flags.pyi +74 -0
  43. a_sync/a_sync/flags.pyx +72 -0
  44. a_sync/a_sync/function.c +37846 -0
  45. a_sync/a_sync/function.cp310-win_amd64.pyd +0 -0
  46. a_sync/a_sync/function.pxd +28 -0
  47. a_sync/a_sync/function.pyi +571 -0
  48. a_sync/a_sync/function.pyx +1381 -0
  49. a_sync/a_sync/method.c +29774 -0
  50. a_sync/a_sync/method.cp310-win_amd64.pyd +0 -0
  51. a_sync/a_sync/method.pxd +9 -0
  52. a_sync/a_sync/method.pyi +525 -0
  53. a_sync/a_sync/method.pyx +1023 -0
  54. a_sync/a_sync/modifiers/__init__.pxd +1 -0
  55. a_sync/a_sync/modifiers/__init__.py +101 -0
  56. a_sync/a_sync/modifiers/cache/__init__.py +160 -0
  57. a_sync/a_sync/modifiers/cache/memory.py +165 -0
  58. a_sync/a_sync/modifiers/limiter.py +132 -0
  59. a_sync/a_sync/modifiers/manager.c +16149 -0
  60. a_sync/a_sync/modifiers/manager.cp310-win_amd64.pyd +0 -0
  61. a_sync/a_sync/modifiers/manager.pxd +5 -0
  62. a_sync/a_sync/modifiers/manager.pyi +219 -0
  63. a_sync/a_sync/modifiers/manager.pyx +299 -0
  64. a_sync/a_sync/modifiers/semaphores.py +173 -0
  65. a_sync/a_sync/property.c +27260 -0
  66. a_sync/a_sync/property.cp310-win_amd64.pyd +0 -0
  67. a_sync/a_sync/property.pyi +376 -0
  68. a_sync/a_sync/property.pyx +819 -0
  69. a_sync/a_sync/singleton.py +63 -0
  70. a_sync/aliases.py +3 -0
  71. a_sync/async_property/__init__.pxd +1 -0
  72. a_sync/async_property/__init__.py +1 -0
  73. a_sync/async_property/cached.c +20386 -0
  74. a_sync/async_property/cached.cp310-win_amd64.pyd +0 -0
  75. a_sync/async_property/cached.pxd +10 -0
  76. a_sync/async_property/cached.pyi +45 -0
  77. a_sync/async_property/cached.pyx +178 -0
  78. a_sync/async_property/proxy.c +34654 -0
  79. a_sync/async_property/proxy.cp310-win_amd64.pyd +0 -0
  80. a_sync/async_property/proxy.pxd +2 -0
  81. a_sync/async_property/proxy.pyi +124 -0
  82. a_sync/async_property/proxy.pyx +474 -0
  83. a_sync/asyncio/__init__.pxd +6 -0
  84. a_sync/asyncio/__init__.py +164 -0
  85. a_sync/asyncio/as_completed.c +18841 -0
  86. a_sync/asyncio/as_completed.cp310-win_amd64.pyd +0 -0
  87. a_sync/asyncio/as_completed.pxd +8 -0
  88. a_sync/asyncio/as_completed.pyi +109 -0
  89. a_sync/asyncio/as_completed.pyx +269 -0
  90. a_sync/asyncio/create_task.c +15902 -0
  91. a_sync/asyncio/create_task.cp310-win_amd64.pyd +0 -0
  92. a_sync/asyncio/create_task.pxd +2 -0
  93. a_sync/asyncio/create_task.pyi +51 -0
  94. a_sync/asyncio/create_task.pyx +271 -0
  95. a_sync/asyncio/gather.c +16679 -0
  96. a_sync/asyncio/gather.cp310-win_amd64.pyd +0 -0
  97. a_sync/asyncio/gather.pyi +107 -0
  98. a_sync/asyncio/gather.pyx +218 -0
  99. a_sync/asyncio/igather.c +12676 -0
  100. a_sync/asyncio/igather.cp310-win_amd64.pyd +0 -0
  101. a_sync/asyncio/igather.pxd +1 -0
  102. a_sync/asyncio/igather.pyi +7 -0
  103. a_sync/asyncio/igather.pyx +182 -0
  104. a_sync/asyncio/sleep.c +9593 -0
  105. a_sync/asyncio/sleep.cp310-win_amd64.pyd +0 -0
  106. a_sync/asyncio/sleep.pyi +14 -0
  107. a_sync/asyncio/sleep.pyx +49 -0
  108. a_sync/debugging.c +15362 -0
  109. a_sync/debugging.cp310-win_amd64.pyd +0 -0
  110. a_sync/debugging.pyi +76 -0
  111. a_sync/debugging.pyx +107 -0
  112. a_sync/exceptions.c +13312 -0
  113. a_sync/exceptions.cp310-win_amd64.pyd +0 -0
  114. a_sync/exceptions.pyi +376 -0
  115. a_sync/exceptions.pyx +446 -0
  116. a_sync/executor.py +619 -0
  117. a_sync/functools.c +12738 -0
  118. a_sync/functools.cp310-win_amd64.pyd +0 -0
  119. a_sync/functools.pxd +7 -0
  120. a_sync/functools.pyi +33 -0
  121. a_sync/functools.pyx +139 -0
  122. a_sync/future.py +1497 -0
  123. a_sync/iter.c +37271 -0
  124. a_sync/iter.cp310-win_amd64.pyd +0 -0
  125. a_sync/iter.pxd +11 -0
  126. a_sync/iter.pyi +370 -0
  127. a_sync/iter.pyx +981 -0
  128. a_sync/primitives/__init__.pxd +1 -0
  129. a_sync/primitives/__init__.py +53 -0
  130. a_sync/primitives/_debug.c +15757 -0
  131. a_sync/primitives/_debug.cp310-win_amd64.pyd +0 -0
  132. a_sync/primitives/_debug.pxd +12 -0
  133. a_sync/primitives/_debug.pyi +52 -0
  134. a_sync/primitives/_debug.pyx +223 -0
  135. a_sync/primitives/_loggable.c +11529 -0
  136. a_sync/primitives/_loggable.cp310-win_amd64.pyd +0 -0
  137. a_sync/primitives/_loggable.pxd +4 -0
  138. a_sync/primitives/_loggable.pyi +66 -0
  139. a_sync/primitives/_loggable.pyx +102 -0
  140. a_sync/primitives/locks/__init__.pxd +8 -0
  141. a_sync/primitives/locks/__init__.py +17 -0
  142. a_sync/primitives/locks/counter.c +17679 -0
  143. a_sync/primitives/locks/counter.cp310-win_amd64.pyd +0 -0
  144. a_sync/primitives/locks/counter.pxd +12 -0
  145. a_sync/primitives/locks/counter.pyi +151 -0
  146. a_sync/primitives/locks/counter.pyx +260 -0
  147. a_sync/primitives/locks/event.c +17063 -0
  148. a_sync/primitives/locks/event.cp310-win_amd64.pyd +0 -0
  149. a_sync/primitives/locks/event.pxd +22 -0
  150. a_sync/primitives/locks/event.pyi +43 -0
  151. a_sync/primitives/locks/event.pyx +185 -0
  152. a_sync/primitives/locks/prio_semaphore.c +25590 -0
  153. a_sync/primitives/locks/prio_semaphore.cp310-win_amd64.pyd +0 -0
  154. a_sync/primitives/locks/prio_semaphore.pxd +25 -0
  155. a_sync/primitives/locks/prio_semaphore.pyi +217 -0
  156. a_sync/primitives/locks/prio_semaphore.pyx +597 -0
  157. a_sync/primitives/locks/semaphore.c +26509 -0
  158. a_sync/primitives/locks/semaphore.cp310-win_amd64.pyd +0 -0
  159. a_sync/primitives/locks/semaphore.pxd +21 -0
  160. a_sync/primitives/locks/semaphore.pyi +197 -0
  161. a_sync/primitives/locks/semaphore.pyx +454 -0
  162. a_sync/primitives/queue.py +1022 -0
  163. a_sync/py.typed +0 -0
  164. a_sync/sphinx/__init__.py +3 -0
  165. a_sync/sphinx/ext.py +289 -0
  166. a_sync/task.py +932 -0
  167. a_sync/utils/__init__.py +105 -0
  168. a_sync/utils/iterators.py +297 -0
  169. a_sync/utils/repr.c +15799 -0
  170. a_sync/utils/repr.cp310-win_amd64.pyd +0 -0
  171. a_sync/utils/repr.pyi +2 -0
  172. a_sync/utils/repr.pyx +73 -0
  173. ez_a_sync-0.32.29.dist-info/METADATA +367 -0
  174. ez_a_sync-0.32.29.dist-info/RECORD +177 -0
  175. ez_a_sync-0.32.29.dist-info/WHEEL +5 -0
  176. ez_a_sync-0.32.29.dist-info/licenses/LICENSE.txt +17 -0
  177. ez_a_sync-0.32.29.dist-info/top_level.txt +1 -0
Binary file
@@ -0,0 +1,9 @@
1
+ from a_sync.a_sync.function cimport _ASyncFunction
2
+ cdef class _ASyncBoundMethod(_ASyncFunction):
3
+ cdef readonly object __weakself__
4
+ cdef readonly bint _is_async_def
5
+ cdef readonly object _cache_handle
6
+ cdef object c_map(self, tuple iterables, object concurrency, str task_name, dict kwargs)
7
+ cdef object __c_self__(self)
8
+ cdef bint _is_a_sync_instance(object instance)
9
+ cdef void _update_cache_timer(str field_name, object instance, _ASyncBoundMethod bound)
@@ -0,0 +1,525 @@
1
+ """
2
+ This module provides classes for implementing dual-functional sync/async methods in Python.
3
+
4
+ It includes descriptors and bound methods that can be used to create flexible
5
+ asynchronous interfaces, allowing methods to be called both synchronously and
6
+ asynchronously based on various conditions and configurations.
7
+ """
8
+
9
+ from a_sync._typing import *
10
+ import functools
11
+ import logging
12
+ import weakref
13
+ from _typeshed import Incomplete
14
+ from a_sync import TaskMapping as TaskMapping
15
+ from a_sync.a_sync._descriptor import ASyncDescriptor as ASyncDescriptor
16
+ from a_sync.a_sync.abstract import ASyncABC as ASyncABC
17
+ from a_sync.a_sync.function import (
18
+ ASyncFunction as ASyncFunction,
19
+ ASyncFunctionAsyncDefault as ASyncFunctionAsyncDefault,
20
+ ASyncFunctionSyncDefault as ASyncFunctionSyncDefault,
21
+ )
22
+ from typing import Any, final
23
+
24
+ METHOD_CACHE_TTL: Literal[3600]
25
+ logger: logging.Logger
26
+
27
+ class ASyncMethodDescriptor(ASyncDescriptor[I, P, T]):
28
+ """
29
+ A descriptor for managing methods that can be called both synchronously and asynchronously.
30
+
31
+ This class provides the core functionality for binding methods to instances and determining
32
+ the execution mode ("sync" or "async") based on various conditions, such as the instance type,
33
+ the method\'s default setting, or specific flags passed during the method call.
34
+
35
+ The descriptor is responsible for creating an appropriate bound method when accessed,
36
+ which is the actual object that can be called in both synchronous and asynchronous contexts.
37
+ It can create different types of bound methods (`ASyncBoundMethodSyncDefault`,
38
+ `ASyncBoundMethodAsyncDefault`, or `ASyncBoundMethod`) based on the default mode or instance type.
39
+
40
+ If the default mode is explicitly set to "sync" or "async", it creates `ASyncBoundMethodSyncDefault`
41
+ or `ASyncBoundMethodAsyncDefault` respectively. If neither is set, it defaults to creating an
42
+ `ASyncBoundMethod`. For instances of :class:`ASyncABC`, it checks the `__a_sync_instance_should_await__`
43
+ attribute to decide the type of bound method to create.
44
+
45
+ It also manages cache handles for bound methods and prevents setting or deleting the descriptor.
46
+
47
+ Examples:
48
+ >>> class MyClass:
49
+ ... @ASyncMethodDescriptor
50
+ ... async def my_method(self):
51
+ ... return "Hello, World!"
52
+ ...
53
+ >>> obj = MyClass()
54
+ >>> await obj.my_method()
55
+ \'Hello, World!\'
56
+ >>> obj.my_method(sync=True)
57
+ \'Hello, World!\'
58
+
59
+ See Also:
60
+ - :class:`ASyncBoundMethod`
61
+ - :class:`ASyncFunction`
62
+ """
63
+
64
+ __wrapped__: AnyFn[P, T]
65
+ async def __call__(self, instance: I, *args: P.args, **kwargs: P.kwargs) -> T:
66
+ """
67
+ Asynchronously call the method.
68
+
69
+ Args:
70
+ instance: The instance the method is bound to.
71
+ *args: Positional arguments.
72
+ **kwargs: Keyword arguments.
73
+
74
+ Examples:
75
+ >>> descriptor = ASyncMethodDescriptor(my_async_function)
76
+ >>> await descriptor(instance, arg1, arg2, kwarg1=value1)
77
+ """
78
+
79
+ @overload
80
+ def __get__(self, instance: None, owner: Type[I]) -> Self: ...
81
+ @overload
82
+ def __get__(self, instance: I, owner: Type[I]) -> ASyncBoundMethod[I, P, T]: ...
83
+ def __set__(self, instance, value) -> None:
84
+ """
85
+ Prevent setting the descriptor.
86
+
87
+ Args:
88
+ instance: The instance.
89
+ value: The value to set.
90
+
91
+ Raises:
92
+ RuntimeError: Always raised to prevent setting.
93
+
94
+ Examples:
95
+ >>> descriptor = ASyncMethodDescriptor(my_function)
96
+ >>> descriptor.__set__(instance, value)
97
+ RuntimeError: cannot set field_name, descriptor is what you get. sorry.
98
+ """
99
+
100
+ def __delete__(self, instance) -> None:
101
+ """
102
+ Prevent deleting the descriptor.
103
+
104
+ Args:
105
+ instance: The instance.
106
+
107
+ Raises:
108
+ RuntimeError: Always raised to prevent deletion.
109
+
110
+ Examples:
111
+ >>> descriptor = ASyncMethodDescriptor(my_function)
112
+ >>> descriptor.__delete__(instance)
113
+ RuntimeError: cannot delete field_name, you're stuck with descriptor forever. sorry.
114
+ """
115
+
116
+ @functools.cached_property
117
+ def __is_async_def__(self) -> bool:
118
+ """
119
+ Check if the wrapped function is a coroutine function.
120
+
121
+ Examples:
122
+ >>> descriptor = ASyncMethodDescriptor(my_function)
123
+ >>> descriptor.__is_async_def__
124
+ True
125
+ """
126
+
127
+ @final
128
+ class ASyncMethodDescriptorSyncDefault(ASyncMethodDescriptor[I, P, T]):
129
+ """
130
+ A descriptor for :class:`ASyncBoundMethodSyncDefault` objects.
131
+
132
+ This class extends :class:`ASyncMethodDescriptor` to provide a synchronous
133
+ default behavior for method calls. It specifically creates `ASyncBoundMethodSyncDefault`
134
+ instances, which are specialized versions of `ASyncBoundMethod` with synchronous default behavior.
135
+
136
+ Examples:
137
+ >>> class MyClass:
138
+ ... @ASyncMethodDescriptorSyncDefault
139
+ ... def my_method(self):
140
+ ... return "Hello, World!"
141
+ ...
142
+ >>> obj = MyClass()
143
+ >>> obj.my_method()
144
+ \'Hello, World!\'
145
+ >>> coro = obj.my_method(sync=False)
146
+ >>> coro
147
+ <coroutine object MyClass.my_method at 0x7fb4f5fb49c0>
148
+ >>> await coro
149
+ \'Hello, World!\'
150
+
151
+ See Also:
152
+ - :class:`ASyncBoundMethodSyncDefault`
153
+ - :class:`ASyncFunctionSyncDefault`
154
+ """
155
+
156
+ default: str
157
+ any: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], bool]
158
+ all: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], bool]
159
+ min: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], T]
160
+ max: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], T]
161
+ sum: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], T]
162
+ @overload
163
+ def __get__(
164
+ self, instance: None, owner: Type[I] = None
165
+ ) -> ASyncMethodDescriptorSyncDefault[I, P, T]: ...
166
+ @overload
167
+ def __get__(
168
+ self, instance: I, owner: Type[I] = None
169
+ ) -> ASyncBoundMethodSyncDefault[I, P, T]: ...
170
+
171
+ @final
172
+ class ASyncMethodDescriptorAsyncDefault(ASyncMethodDescriptor[I, P, T]):
173
+ """
174
+ A descriptor for asynchronous methods with an asynchronous default.
175
+
176
+ This class extends :class:`ASyncMethodDescriptor` to provide an asynchronous default
177
+ behavior for method calls. It specifically creates `ASyncBoundMethodAsyncDefault`
178
+ instances, which are specialized versions of `ASyncBoundMethod` with asynchronous default behavior.
179
+
180
+ Examples:
181
+ >>> class MyClass:
182
+ ... @ASyncMethodDescriptorAsyncDefault
183
+ ... async def my_method(self):
184
+ ... return "Hello, World!"
185
+ ...
186
+ >>> obj = MyClass()
187
+ >>> coro = obj.my_method()
188
+ >>> coro
189
+ <coroutine object MyClass.my_method at 0x7fb4f5fb49c0>
190
+ >>> await coro
191
+ >>> obj.my_method(sync=True)
192
+ \'Hello, World!\'
193
+
194
+ See Also:
195
+ - :class:`ASyncBoundMethodAsyncDefault`
196
+ - :class:`ASyncFunctionAsyncDefault`
197
+ """
198
+
199
+ default: str
200
+ any: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], bool]
201
+ all: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], bool]
202
+ min: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], T]
203
+ max: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], T]
204
+ sum: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], T]
205
+ @overload
206
+ def __get__(
207
+ self, instance: None, owner: Type[I]
208
+ ) -> ASyncMethodDescriptorAsyncDefault[I, P, T]: ...
209
+ @overload
210
+ def __get__(self, instance: I, owner: Type[I]) -> ASyncBoundMethodAsyncDefault[I, P, T]: ...
211
+
212
+ class ASyncBoundMethod(ASyncFunction[P, T], Generic[I, P, T]):
213
+ """
214
+ A bound method that can be called both synchronously and asynchronously.
215
+
216
+ This class represents a method bound to an instance, which can be called
217
+ either synchronously or asynchronously based on various conditions. It handles
218
+ caching of bound methods and includes logic for determining whether to await
219
+ the method call based on flags or default settings.
220
+
221
+ Examples:
222
+ >>> class MyClass:
223
+ ... def __init__(self, value):
224
+ ... self.value = value
225
+ ...
226
+ ... @ASyncMethodDescriptor
227
+ ... async def my_method(self):
228
+ ... return self.value
229
+ ...
230
+ >>> obj = MyClass(42)
231
+ >>> await obj.my_method()
232
+ 42
233
+ >>> obj.my_method(sync=True)
234
+ 42
235
+
236
+ See Also:
237
+ - :class:`ASyncMethodDescriptor`
238
+ - :class:`ASyncFunction`
239
+ """
240
+
241
+ __weakself__: weakref.ref[I]
242
+ __wrapped__: AnyFn[Concatenate[I, P], T]
243
+ def __init__(
244
+ self,
245
+ instance: I,
246
+ unbound: AnyFn[Concatenate[I, P], T],
247
+ async_def: bool,
248
+ **modifiers: Unpack[ModifierKwargs]
249
+ ) -> None:
250
+ """
251
+ Initialize the bound method.
252
+
253
+ Args:
254
+ instance: The instance to bind the method to.
255
+ unbound: The unbound function.
256
+ async_def: Whether the original function is an async def.
257
+ **modifiers: Additional modifiers for the function.
258
+
259
+ Examples:
260
+ >>> class MyClass:
261
+ ... def __init__(self, value):
262
+ ... self.value = value
263
+ ...
264
+ ... @ASyncMethodDescriptor
265
+ ... async def my_method(self):
266
+ ... return self.value
267
+ ...
268
+ >>> obj = MyClass(42)
269
+ >>> bound_method = ASyncBoundMethod(obj, MyClass.my_method, True)
270
+ """
271
+
272
+ @overload
273
+ def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
274
+ @overload
275
+ def __call__(
276
+ self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
277
+ ) -> Coroutine[Any, Any, T]: ...
278
+ @overload
279
+ def __call__(self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs) -> T: ...
280
+ @overload
281
+ def __call__(
282
+ self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
283
+ ) -> Coroutine[Any, Any, T]: ...
284
+ @overload
285
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]: ...
286
+ @property
287
+ def __self__(self) -> I:
288
+ """
289
+ Get the instance the method is bound to.
290
+
291
+ Raises:
292
+ ReferenceError: If the instance has been garbage collected.
293
+
294
+ Examples:
295
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
296
+ >>> bound_method.__self__
297
+ <MyClass instance>
298
+ """
299
+
300
+ @functools.cached_property
301
+ def __bound_to_a_sync_instance__(self) -> bool:
302
+ """
303
+ Check if the method is bound to an ASyncABC instance.
304
+
305
+ Examples:
306
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
307
+ >>> bound_method.__bound_to_a_sync_instance__
308
+ True
309
+ """
310
+
311
+ def map(
312
+ self,
313
+ *iterables: AnyIterable[I],
314
+ concurrency: Optional[int] = None,
315
+ task_name: str = "",
316
+ **kwargs: P.kwargs
317
+ ) -> TaskMapping[I, T]:
318
+ """
319
+ Create a TaskMapping for this method.
320
+
321
+ Args:
322
+ *iterables: Iterables to map over.
323
+ concurrency: Optional concurrency limit.
324
+ task_name: Optional name for the task.
325
+ **kwargs: Additional keyword arguments.
326
+
327
+ Returns:
328
+ A TaskMapping instance for this method.
329
+
330
+ Examples:
331
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
332
+ >>> task_mapping = bound_method.map(iterable1, iterable2, concurrency=5)
333
+ TODO briefly include how someone would then use task_mapping
334
+ """
335
+
336
+ async def any(
337
+ self,
338
+ *iterables: AnyIterable[I],
339
+ concurrency: Optional[int] = None,
340
+ task_name: str = "",
341
+ **kwargs: P.kwargs
342
+ ) -> bool:
343
+ """
344
+ Check if any of the results are truthy.
345
+
346
+ Args:
347
+ *iterables: Iterables to map over.
348
+ concurrency: Optional concurrency limit.
349
+ task_name: Optional name for the task.
350
+ **kwargs: Additional keyword arguments.
351
+
352
+ Examples:
353
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
354
+ >>> result = await bound_method.any(iterable1, iterable2)
355
+ """
356
+
357
+ async def all(
358
+ self,
359
+ *iterables: AnyIterable[I],
360
+ concurrency: Optional[int] = None,
361
+ task_name: str = "",
362
+ **kwargs: P.kwargs
363
+ ) -> bool:
364
+ """
365
+ Check if all of the results are truthy.
366
+
367
+ Args:
368
+ *iterables: Iterables to map over.
369
+ concurrency: Optional concurrency limit.
370
+ task_name: Optional name for the task.
371
+ **kwargs: Additional keyword arguments.
372
+
373
+ Examples:
374
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
375
+ >>> result = await bound_method.all(iterable1, iterable2)
376
+ """
377
+
378
+ async def min(
379
+ self,
380
+ *iterables: AnyIterable[I],
381
+ concurrency: Optional[int] = None,
382
+ task_name: str = "",
383
+ **kwargs: P.kwargs
384
+ ) -> T:
385
+ """
386
+ Find the minimum result.
387
+
388
+ Args:
389
+ *iterables: Iterables to map over.
390
+ concurrency: Optional concurrency limit.
391
+ task_name: Optional name for the task.
392
+ **kwargs: Additional keyword arguments.
393
+
394
+ Examples:
395
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
396
+ >>> result = await bound_method.min(iterable1, iterable2)
397
+ """
398
+
399
+ async def max(
400
+ self,
401
+ *iterables: AnyIterable[I],
402
+ concurrency: Optional[int] = None,
403
+ task_name: str = "",
404
+ **kwargs: P.kwargs
405
+ ) -> T:
406
+ """
407
+ Find the maximum result.
408
+
409
+ Args:
410
+ *iterables: Iterables to map over.
411
+ concurrency: Optional concurrency limit.
412
+ task_name: Optional name for the task.
413
+ **kwargs: Additional keyword arguments.
414
+
415
+ Examples:
416
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
417
+ >>> result = await bound_method.max(iterable1, iterable2)
418
+ """
419
+
420
+ async def sum(
421
+ self,
422
+ *iterables: AnyIterable[I],
423
+ concurrency: Optional[int] = None,
424
+ task_name: str = "",
425
+ **kwargs: P.kwargs
426
+ ) -> T:
427
+ """
428
+ Calculate the sum of the results.
429
+
430
+ Args:
431
+ *iterables: Iterables to map over.
432
+ concurrency: Optional concurrency limit.
433
+ task_name: Optional name for the task.
434
+ **kwargs: Additional keyword arguments.
435
+
436
+ Examples:
437
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
438
+ >>> result = await bound_method.sum(iterable1, iterable2)
439
+ """
440
+
441
+ class ASyncBoundMethodSyncDefault(ASyncBoundMethod[I, P, T]):
442
+ """
443
+ A bound method with synchronous default behavior.
444
+
445
+ This class is a specialized version of :class:`ASyncBoundMethod` that defaults to synchronous execution.
446
+ It overrides the `__call__` method to enforce synchronous default behavior.
447
+
448
+ Examples:
449
+ >>> class MyClass:
450
+ ... def __init__(self, value):
451
+ ... self.value = value
452
+ ...
453
+ ... @ASyncMethodDescriptorSyncDefault
454
+ ... def my_method(self):
455
+ ... return self.value
456
+ ...
457
+ >>> obj = MyClass(42)
458
+ >>> obj.my_method()
459
+ 42
460
+ >>> await obj.my_method(sync=False)
461
+ 42
462
+
463
+ See Also:
464
+ - :class:`ASyncBoundMethod`
465
+ - :class:`ASyncMethodDescriptorSyncDefault`
466
+ """
467
+
468
+ @overload
469
+ def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
470
+ @overload
471
+ def __call__(
472
+ self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
473
+ ) -> Coroutine[Any, Any, T]: ...
474
+ @overload
475
+ def __call__(self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs) -> T: ...
476
+ @overload
477
+ def __call__(
478
+ self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
479
+ ) -> Coroutine[Any, Any, T]: ...
480
+ @overload
481
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ...
482
+ __call__: Incomplete
483
+
484
+ class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
485
+ """
486
+ A bound method with asynchronous default behavior.
487
+
488
+ This class is a specialized version of :class:`ASyncBoundMethod` that defaults to asynchronous execution.
489
+ It overrides the `__call__` method to enforce asynchronous default behavior.
490
+
491
+ Examples:
492
+ >>> class MyClass:
493
+ ... def __init__(self, value):
494
+ ... self.value = value
495
+ ...
496
+ ... @ASyncMethodDescriptorAsyncDefault
497
+ ... async def my_method(self):
498
+ ... return self.value
499
+ ...
500
+ >>> obj = MyClass(42)
501
+ >>> await obj.my_method()
502
+ 42
503
+ >>> obj.my_method(sync=True)
504
+ 42
505
+
506
+ See Also:
507
+ - :class:`ASyncBoundMethod`
508
+ - :class:`ASyncMethodDescriptorAsyncDefault`
509
+ """
510
+
511
+ @overload
512
+ def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
513
+ @overload
514
+ def __call__(
515
+ self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
516
+ ) -> Coroutine[Any, Any, T]: ...
517
+ @overload
518
+ def __call__(self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs) -> T: ...
519
+ @overload
520
+ def __call__(
521
+ self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
522
+ ) -> Coroutine[Any, Any, T]: ...
523
+ @overload
524
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T]: ...
525
+ __call__: Incomplete