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.
Files changed (32) hide show
  1. {queutils-0.10.1 → queutils-0.11.0}/PKG-INFO +1 -1
  2. {queutils-0.10.1 → queutils-0.11.0}/pyproject.toml +1 -1
  3. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/iterablequeue.py +11 -0
  4. {queutils-0.10.1 → queutils-0.11.0}/tests/test_iterablequeue.py +16 -1
  5. {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/codeql.yml +0 -0
  6. {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/dependency-review.yml +0 -0
  7. {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/python-package.yml +0 -0
  8. {queutils-0.10.1 → queutils-0.11.0}/.github/workflows/python-publish.yml +0 -0
  9. {queutils-0.10.1 → queutils-0.11.0}/.gitignore +0 -0
  10. {queutils-0.10.1 → queutils-0.11.0}/LICENSE +0 -0
  11. {queutils-0.10.1 → queutils-0.11.0}/README.md +0 -0
  12. {queutils-0.10.1 → queutils-0.11.0}/codecov.yml +0 -0
  13. {queutils-0.10.1 → queutils-0.11.0}/demos/asyncqueue_demo.py +0 -0
  14. {queutils-0.10.1 → queutils-0.11.0}/demos/filequeue_demo.py +0 -0
  15. {queutils-0.10.1 → queutils-0.11.0}/demos/iterablequeue_demo.py +0 -0
  16. {queutils-0.10.1 → queutils-0.11.0}/docs/asyncqueue.md +0 -0
  17. {queutils-0.10.1 → queutils-0.11.0}/docs/filequeue.md +0 -0
  18. {queutils-0.10.1 → queutils-0.11.0}/docs/iterablequeue.md +0 -0
  19. {queutils-0.10.1 → queutils-0.11.0}/docs/rm_links +0 -0
  20. {queutils-0.10.1 → queutils-0.11.0}/pypi.md +0 -0
  21. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/__init__.py +0 -0
  22. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/asyncqueue.py +0 -0
  23. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/awrap.py +0 -0
  24. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/countable.py +0 -0
  25. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/eventcounterqueue.py +0 -0
  26. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/filequeue.py +0 -0
  27. {queutils-0.10.1 → queutils-0.11.0}/src/queutils/py.typed +0 -0
  28. {queutils-0.10.1 → queutils-0.11.0}/tests/test_asyncqueue.py +0 -0
  29. {queutils-0.10.1 → queutils-0.11.0}/tests/test_awrap.py +0 -0
  30. {queutils-0.10.1 → queutils-0.11.0}/tests/test_demos.py +0 -0
  31. {queutils-0.10.1 → queutils-0.11.0}/tests/test_eventcounterqueue.py +0 -0
  32. {queutils-0.10.1 → queutils-0.11.0}/tests/test_filequeue.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: queutils
3
- Version: 0.10.1
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "queutils"
3
- version = "0.10.1"
3
+ version = "0.11.0"
4
4
  authors = [{ name = "Jylpah", email = "jylpah@gmail.com" }]
5
5
  description = "Handy Python Queue utilies"
6
6
  readme = { file = "pypi.md", content-type = "text/markdown" }
@@ -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