queutils 0.10.1__tar.gz → 0.11.0__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.
- {queutils-0.10.1 → queutils-0.11.0}/PKG-INFO +1 -1
- {queutils-0.10.1 → queutils-0.11.0}/pyproject.toml +1 -1
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/iterablequeue.py +11 -0
- {queutils-0.10.1 → queutils-0.11.0}/tests/test_iterablequeue.py +16 -1
- {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/codeql.yml +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/dependency-review.yml +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/python-package.yml +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/python-publish.yml +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/.gitignore +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/LICENSE +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/README.md +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/codecov.yml +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/demos/asyncqueue_demo.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/demos/filequeue_demo.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/demos/iterablequeue_demo.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/docs/asyncqueue.md +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/docs/filequeue.md +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/docs/iterablequeue.md +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/docs/rm_links +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/pypi.md +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/__init__.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/asyncqueue.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/awrap.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/countable.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/eventcounterqueue.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/filequeue.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/src/queutils/py.typed +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/tests/test_asyncqueue.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/tests/test_awrap.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/tests/test_demos.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/tests/test_eventcounterqueue.py +0 -0
- {queutils-0.10.1 → queutils-0.11.0}/tests/test_filequeue.py +0 -0
|
@@ -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
|
""" "
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pytest # type: ignore
|
|
2
|
-
from asyncio.queues import QueueEmpty, QueueFull
|
|
2
|
+
from asyncio.queues import QueueEmpty, QueueFull, Queue
|
|
3
3
|
from asyncio import (
|
|
4
4
|
Task,
|
|
5
5
|
create_task,
|
|
@@ -9,6 +9,7 @@ from asyncio import (
|
|
|
9
9
|
TimeoutError,
|
|
10
10
|
CancelledError,
|
|
11
11
|
)
|
|
12
|
+
from typing import Optional
|
|
12
13
|
from random import random
|
|
13
14
|
|
|
14
15
|
from queutils import IterableQueue, QueueDone
|
|
@@ -281,3 +282,17 @@ async def test_8_aiter_1_item(test_interablequeue_int: IterableQueue[int]):
|
|
|
281
282
|
)
|
|
282
283
|
except TimeoutError:
|
|
283
284
|
assert False, "await IterableQueue.join() failed with an empty queue finished"
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
@pytest.mark.asyncio
|
|
288
|
+
async def test_9_from_queue():
|
|
289
|
+
"""Test from_queue class method"""
|
|
290
|
+
Q = Queue[Optional[int]](maxsize=QSIZE)
|
|
291
|
+
iq = IterableQueue.from_queue(Q)
|
|
292
|
+
assert iq.maxsize == Q.maxsize, "maxsize does not match"
|
|
293
|
+
assert iq.qsize() == Q.qsize(), "qsize does not match"
|
|
294
|
+
assert iq.empty() == Q.empty(), "empty() does not match"
|
|
295
|
+
assert iq.full() == Q.full(), "full() does not match"
|
|
296
|
+
|
|
297
|
+
with pytest.raises(TypeError):
|
|
298
|
+
IterableQueue.from_queue("not a queue")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|