queutils 0.10.0__py3-none-any.whl → 0.11.0__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.
- queutils/iterablequeue.py +14 -3
- {queutils-0.10.0.dist-info → queutils-0.11.0.dist-info}/METADATA +6 -7
- {queutils-0.10.0.dist-info → queutils-0.11.0.dist-info}/RECORD +5 -5
- {queutils-0.10.0.dist-info → queutils-0.11.0.dist-info}/WHEEL +0 -0
- {queutils-0.10.0.dist-info → queutils-0.11.0.dist-info}/licenses/LICENSE +0 -0
queutils/iterablequeue.py
CHANGED
|
@@ -50,7 +50,7 @@ class IterableQueue(Queue[T], AsyncIterable[T], Countable):
|
|
|
50
50
|
- AsyncIterable(): async for item in queue:
|
|
51
51
|
- Automatic termination of the consumers when the queue has been emptied with QueueDone exception
|
|
52
52
|
- Producers must be registered with add_producer() and they must notify the queue
|
|
53
|
-
with
|
|
53
|
+
with finish_producer() once they have finished adding items
|
|
54
54
|
- Countable interface to count number of items task_done() through 'count' property
|
|
55
55
|
|
|
56
56
|
IterableQueue stages:
|
|
@@ -82,6 +82,17 @@ class IterableQueue(Queue[T], AsyncIterable[T], Countable):
|
|
|
82
82
|
|
|
83
83
|
self._empty.clear() # this will be tested only after queue is filled
|
|
84
84
|
|
|
85
|
+
@classmethod
|
|
86
|
+
def from_queue(cls, Q: Queue[Optional[T]]) -> "IterableQueue[T]":
|
|
87
|
+
"""
|
|
88
|
+
Create IterableQueue from existing asyncio.Queue
|
|
89
|
+
"""
|
|
90
|
+
if not isinstance(Q, Queue):
|
|
91
|
+
raise TypeError("Q must be an instance of asyncio.Queue")
|
|
92
|
+
iq: IterableQueue[T] = cls(maxsize=Q.maxsize)
|
|
93
|
+
iq._Q = Q
|
|
94
|
+
return iq
|
|
95
|
+
|
|
85
96
|
@property
|
|
86
97
|
def is_filled(self) -> bool:
|
|
87
98
|
""" "
|
|
@@ -166,7 +177,7 @@ class IterableQueue(Queue[T], AsyncIterable[T], Countable):
|
|
|
166
177
|
"""
|
|
167
178
|
Producer has finished adding items to the queue.
|
|
168
179
|
Once the last producers has finished, the queue is_filled.
|
|
169
|
-
- all:
|
|
180
|
+
- all: finish_producer() queue for all producers at once
|
|
170
181
|
|
|
171
182
|
Return True if the last producer is 'finished'
|
|
172
183
|
"""
|
|
@@ -177,7 +188,7 @@ class IterableQueue(Queue[T], AsyncIterable[T], Countable):
|
|
|
177
188
|
self._producers -= 1
|
|
178
189
|
|
|
179
190
|
if self._producers < 0:
|
|
180
|
-
raise ValueError("Too many
|
|
191
|
+
raise ValueError("Too many finish_producer() calls")
|
|
181
192
|
elif all or self._producers == 0:
|
|
182
193
|
self._filled.set()
|
|
183
194
|
self._producers = 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queutils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Handy Python Queue utilies
|
|
5
5
|
Project-URL: Homepage, https://github.com/Jylpah/queutils
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/Jylpah/queutils/issues
|
|
@@ -58,11 +58,10 @@ an `asyncio.Queue` compatible interface to a (non-async) managed `multiprocessin
|
|
|
58
58
|
`IterableQueue` is an `asyncio.Queue` subclass that is `AsyncIterable[T]` i.e. it can be
|
|
59
59
|
iterated in `async for` loop. `IterableQueue` terminates automatically when the queue has been filled and emptied.
|
|
60
60
|
|
|
61
|
-
The `IterableQueue` requires "producers" (functions adding items to the queue) to register themselves with `add_producer()` call
|
|
62
|
-
|
|
63
|
-
producers are "finished", the queue enters into "filled" state and no new items can be added. Once
|
|
64
|
-
|
|
65
|
-
`raise QueueDone` exception.
|
|
61
|
+
The `IterableQueue` requires "producers" (functions adding items to the queue) to register themselves with `add_producer()` call. It keeps count of registered producers. When a producer "finishes" adding items to the queue,
|
|
62
|
+
it needs to unregister itself with `finish_producer()` call. Once all the registered
|
|
63
|
+
producers are "finished", the queue enters into "filled" state and no new items can be added. Once a "filled" queue has been emptied, the queue becomes "done" and
|
|
64
|
+
all new `get()` calls to the queue will `raise QueueDone` exception.
|
|
66
65
|
|
|
67
66
|
## Features
|
|
68
67
|
|
|
@@ -70,7 +69,7 @@ producers are "finished", the queue enters into "filled" state and no new items
|
|
|
70
69
|
- `AsyncIterable` support: `async for item in queue:`
|
|
71
70
|
- Automatic termination of the consumers with `QueueDone` exception when the queue has been emptied
|
|
72
71
|
- Producers must be registered with `add_producer()` and they must notify the queue
|
|
73
|
-
with `
|
|
72
|
+
with `finish_producer()` once they have finished adding items
|
|
74
73
|
- Countable interface to count number of items task_done() through `count` property
|
|
75
74
|
|
|
76
75
|
# EventCounterQueue
|
|
@@ -4,9 +4,9 @@ queutils/awrap.py,sha256=QydWBLmyNIHpYrRwVFn1RWjbQKRnJr61u-DYl7d3F7w,1293
|
|
|
4
4
|
queutils/countable.py,sha256=YSi7ILf9CuB5Tm3T4UUMEFlveqzqcmomfqJAlLGHEz8,172
|
|
5
5
|
queutils/eventcounterqueue.py,sha256=9CvgfnWmvXrMr3h-RiQyIVIBXqOnGvohql_ADvdlmxo,2913
|
|
6
6
|
queutils/filequeue.py,sha256=J_UK3VHKaM4ELFzedtj6lDmlXas8O732aC0nO8zNzNo,5256
|
|
7
|
-
queutils/iterablequeue.py,sha256=
|
|
7
|
+
queutils/iterablequeue.py,sha256=_crzGtifm0cmxQuyOF5grVveJjkUp4eR22RRMZqqOM0,9092
|
|
8
8
|
queutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
queutils-0.
|
|
10
|
-
queutils-0.
|
|
11
|
-
queutils-0.
|
|
12
|
-
queutils-0.
|
|
9
|
+
queutils-0.11.0.dist-info/METADATA,sha256=etPt_8pP0P8k6FVEQVetf_j92Rz4mYCTx1aR4sDxTvM,4708
|
|
10
|
+
queutils-0.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
queutils-0.11.0.dist-info/licenses/LICENSE,sha256=J1zeIKU2JVQmhwO2hHQDK8WR6zjVZ-wX8r7ZlL45AbI,1063
|
|
12
|
+
queutils-0.11.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|