haiway 0.26.0__py3-none-any.whl → 0.26.1__py3-none-any.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.
- haiway/helpers/concurrent.py +8 -9
- haiway/helpers/files.py +4 -4
- {haiway-0.26.0.dist-info → haiway-0.26.1.dist-info}/METADATA +1 -1
- {haiway-0.26.0.dist-info → haiway-0.26.1.dist-info}/RECORD +6 -6
- {haiway-0.26.0.dist-info → haiway-0.26.1.dist-info}/WHEEL +0 -0
- {haiway-0.26.0.dist-info → haiway-0.26.1.dist-info}/licenses/LICENSE +0 -0
haiway/helpers/concurrent.py
CHANGED
@@ -3,8 +3,8 @@ from collections.abc import (
|
|
3
3
|
AsyncIterable,
|
4
4
|
AsyncIterator,
|
5
5
|
Callable,
|
6
|
-
Collection,
|
7
6
|
Coroutine,
|
7
|
+
Iterable,
|
8
8
|
MutableSequence,
|
9
9
|
Sequence,
|
10
10
|
)
|
@@ -20,7 +20,7 @@ __all__ = (
|
|
20
20
|
|
21
21
|
|
22
22
|
async def process_concurrently[Element]( # noqa: C901, PLR0912
|
23
|
-
source:
|
23
|
+
source: AsyncIterable[Element],
|
24
24
|
/,
|
25
25
|
handler: Callable[[Element], Coroutine[Any, Any, None]],
|
26
26
|
*,
|
@@ -80,8 +80,7 @@ async def process_concurrently[Element]( # noqa: C901, PLR0912
|
|
80
80
|
assert concurrent_tasks > 0 # nosec: B101
|
81
81
|
running: set[Task[None]] = set()
|
82
82
|
try:
|
83
|
-
|
84
|
-
element: Element = await anext(source)
|
83
|
+
async for element in source:
|
85
84
|
running.add(ctx.spawn(handler, element))
|
86
85
|
if len(running) < concurrent_tasks:
|
87
86
|
continue # keep spawning tasks
|
@@ -132,7 +131,7 @@ async def process_concurrently[Element]( # noqa: C901, PLR0912
|
|
132
131
|
async def execute_concurrently[Element, Result](
|
133
132
|
handler: Callable[[Element], Coroutine[Any, Any, Result]],
|
134
133
|
/,
|
135
|
-
elements:
|
134
|
+
elements: Iterable[Element],
|
136
135
|
*,
|
137
136
|
concurrent_tasks: int = 2,
|
138
137
|
) -> Sequence[Result]: ...
|
@@ -142,7 +141,7 @@ async def execute_concurrently[Element, Result](
|
|
142
141
|
async def execute_concurrently[Element, Result](
|
143
142
|
handler: Callable[[Element], Coroutine[Any, Any, Result]],
|
144
143
|
/,
|
145
|
-
elements:
|
144
|
+
elements: Iterable[Element],
|
146
145
|
*,
|
147
146
|
concurrent_tasks: int = 2,
|
148
147
|
return_exceptions: Literal[True],
|
@@ -152,7 +151,7 @@ async def execute_concurrently[Element, Result](
|
|
152
151
|
async def execute_concurrently[Element, Result]( # noqa: C901
|
153
152
|
handler: Callable[[Element], Coroutine[Any, Any, Result]],
|
154
153
|
/,
|
155
|
-
elements:
|
154
|
+
elements: Iterable[Element],
|
156
155
|
*,
|
157
156
|
concurrent_tasks: int = 2,
|
158
157
|
return_exceptions: bool = False,
|
@@ -175,8 +174,8 @@ async def execute_concurrently[Element, Result]( # noqa: C901
|
|
175
174
|
----------
|
176
175
|
handler : Callable[[Element], Coroutine[Any, Any, Result]]
|
177
176
|
A coroutine function that processes each element and returns a result.
|
178
|
-
elements :
|
179
|
-
A
|
177
|
+
elements : Iterable[Element]
|
178
|
+
A source of elements to process. The source size determines
|
180
179
|
the result sequence length.
|
181
180
|
concurrent_tasks : int, default=2
|
182
181
|
Maximum number of concurrent tasks. Must be greater than 0. Higher
|
haiway/helpers/files.py
CHANGED
@@ -188,7 +188,7 @@ class FileAccessing(Protocol):
|
|
188
188
|
locking, and resource management.
|
189
189
|
"""
|
190
190
|
|
191
|
-
|
191
|
+
def __call__(
|
192
192
|
self,
|
193
193
|
path: Path | str,
|
194
194
|
create: bool,
|
@@ -275,7 +275,7 @@ def _close_file_handle(
|
|
275
275
|
os.close(file_handle)
|
276
276
|
|
277
277
|
|
278
|
-
|
278
|
+
def _file_access_context(
|
279
279
|
path: Path | str,
|
280
280
|
create: bool,
|
281
281
|
exclusive: bool,
|
@@ -375,7 +375,7 @@ class FileAccess(State):
|
|
375
375
|
"""
|
376
376
|
|
377
377
|
@classmethod
|
378
|
-
|
378
|
+
def open(
|
379
379
|
cls,
|
380
380
|
path: Path | str,
|
381
381
|
create: bool = False,
|
@@ -412,7 +412,7 @@ class FileAccess(State):
|
|
412
412
|
If the file cannot be opened with the specified parameters, or if
|
413
413
|
a file is already open in the current context scope
|
414
414
|
"""
|
415
|
-
return
|
415
|
+
return ctx.state(cls).accessing(
|
416
416
|
path,
|
417
417
|
create=create,
|
418
418
|
exclusive=exclusive,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: haiway
|
3
|
-
Version: 0.26.
|
3
|
+
Version: 0.26.1
|
4
4
|
Summary: Framework for dependency injection and state management within structured concurrency model.
|
5
5
|
Project-URL: Homepage, https://miquido.com
|
6
6
|
Project-URL: Repository, https://github.com/miquido/haiway.git
|
@@ -12,8 +12,8 @@ haiway/context/types.py,sha256=LoW8238TTdbUgmxyHDi0LVc8M8ZwTHLWKkAPttTsTeg,746
|
|
12
12
|
haiway/helpers/__init__.py,sha256=gyKM1mWyuQwSx_2ajpI0UF1nA8l5D7wrzZOt9XUkWJA,780
|
13
13
|
haiway/helpers/asynchrony.py,sha256=Ddj8UdXhVczAbAC-rLpyhWa4RJ_W2Eolo45Veorq7_4,5362
|
14
14
|
haiway/helpers/caching.py,sha256=BqgcUGQSAmXsuLi5V8EwlZzuGyutHOn1V4k7BHsGKeg,14347
|
15
|
-
haiway/helpers/concurrent.py,sha256=
|
16
|
-
haiway/helpers/files.py,sha256=
|
15
|
+
haiway/helpers/concurrent.py,sha256=kTcm_wLAKqVQOKgTHIKwbkMX5hJ5GIXOAc5RRIUvbo4,13063
|
16
|
+
haiway/helpers/files.py,sha256=MzGR-GF8FpBzSihDeen7wdxmX2R-JjAT1MB9aMW-8-g,11626
|
17
17
|
haiway/helpers/observability.py,sha256=R4md41g7iTslzvtRaY5W9pgXqmuzJuGByjFb6vsO4W4,10994
|
18
18
|
haiway/helpers/retries.py,sha256=OH__I9e-PUFxcSwuQLIzJ9F1MwXgbz1Ur4jEjJiOmjQ,8974
|
19
19
|
haiway/helpers/throttling.py,sha256=KBWUSHdKVMC5_nRMmmoPNwfp-3AcerQ6OczJa9gNLM0,5796
|
@@ -40,7 +40,7 @@ haiway/utils/mimic.py,sha256=xaZiUKp096QFfdSw7cNIKEWt2UIS7vf880KF54gny38,1831
|
|
40
40
|
haiway/utils/noop.py,sha256=U8ocfoCgt-pY0owJDPtrRrj53cabeIXH9qCKWMQnoRk,1336
|
41
41
|
haiway/utils/queue.py,sha256=6v2u3pA6A44IuCCTOjmCt3yLyOcm7PCRnrIGo25j-1o,6402
|
42
42
|
haiway/utils/stream.py,sha256=lXaeveTY0-AYG5xVzcQYaiC6SUD5fUtHoMXiQcrQAAM,5723
|
43
|
-
haiway-0.26.
|
44
|
-
haiway-0.26.
|
45
|
-
haiway-0.26.
|
46
|
-
haiway-0.26.
|
43
|
+
haiway-0.26.1.dist-info/METADATA,sha256=IEiaciUkopUmCqO7MxJZdfjUrELAI_tDRGBvFL8jUCg,4919
|
44
|
+
haiway-0.26.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
45
|
+
haiway-0.26.1.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
|
46
|
+
haiway-0.26.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|