caffeinism-utils 0.0.170__py3-none-any.whl → 0.0.171__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.
@@ -1,6 +1,6 @@
1
1
  import asyncio
2
2
  import time
3
- from typing import AsyncGenerator, Generic, TypeVar
3
+ from typing import AsyncGenerator, AsyncIterable, Generic, TypeVar
4
4
 
5
5
  from .asyncio import run_in_threadpool
6
6
  from .utils import DummyStopIteration, next_without_stop_iteration
@@ -33,7 +33,22 @@ class StreamQueue(Generic[T]):
33
33
  def __init__(self):
34
34
  self.queue = asyncio.Queue[T]()
35
35
 
36
- def put(self, data: T) -> T:
36
+ def put(self, data: T) -> None:
37
+ return self.queue.put(data)
38
+
39
+ async def __aiter__(self) -> AsyncGenerator[T]:
40
+ while (it := await self.queue.get()) is not __CLOSE:
41
+ yield it
42
+
43
+ async def close(self):
44
+ await self.queue.put(__CLOSE)
45
+
46
+
47
+ class StreamIteratorQueue(Generic[T]):
48
+ def __init__(self):
49
+ self.queue = asyncio.Queue[AsyncIterable[T]]()
50
+
51
+ def put(self, data: AsyncIterable[T]) -> None:
37
52
  return self.queue.put(data)
38
53
 
39
54
  async def __aiter__(self) -> AsyncGenerator[T]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: caffeinism-utils
3
- Version: 0.0.170
3
+ Version: 0.0.171
4
4
  Summary:
5
5
  Author: Kim Minjong
6
6
  Author-email: make.dirty.code@gmail.com
@@ -1,5 +1,5 @@
1
1
  caffeinism_utils/__init__.py,sha256=MER0q-NVosxQWibvx3a3bKwxRWGVXWeso9-qaU6oH_E,43
2
- caffeinism_utils/aiteration.py,sha256=PD2PMU4rkjz2xlVDyBiNd19_-2zBpF3KWrIGS3QNl_c,1130
2
+ caffeinism_utils/aiteration.py,sha256=Ui3ElY6l4rVNws1Mo5V7Uf3DtDwFiUnicklypRH7QTc,1557
3
3
  caffeinism_utils/asyncio.py,sha256=33yJ51vY0JvS6HJiBsEXXxAE3UlpLeudK8tanlu599Y,4811
4
4
  caffeinism_utils/av/__init__.py,sha256=J7dtpfW9R9BH-HJmlubAaFMqcEOMOu--zH64XJ7A2hI,423
5
5
  caffeinism_utils/av/codecs.py,sha256=gkOeazEqJWC1fRTLGpjdQbeorpVZpRHDzN7Ky01AML8,3360
@@ -11,6 +11,6 @@ caffeinism_utils/iteration.py,sha256=7BddGudGRBmNyJi3cTpmcQ2zWplu5zjxYCN4J_cWe3c
11
11
  caffeinism_utils/prefetch.py,sha256=yNTbBaSF-BA5iA1zUfnWVvcMm3br5nlBmPgvBMXHO7I,4144
12
12
  caffeinism_utils/utils.py,sha256=-g0DDuiCrck4xjN9T5ZUaklClXqDLCfOB6PKN4D8mlE,927
13
13
  caffeinism_utils/zip.py,sha256=L1d8qfphao-iD5G7bDu4LMQNg6ULc4kCqUk5gJbhSdE,1679
14
- caffeinism_utils-0.0.170.dist-info/METADATA,sha256=f0uoS1I0M3QiGiOm4c6n3K9X7SJJIuihVUcbBVcWMkQ,899
15
- caffeinism_utils-0.0.170.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
16
- caffeinism_utils-0.0.170.dist-info/RECORD,,
14
+ caffeinism_utils-0.0.171.dist-info/METADATA,sha256=d8yi9lAciIMmXTmdd9Sb5GPSmYUrycAg1p2wvyDwsa8,899
15
+ caffeinism_utils-0.0.171.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
16
+ caffeinism_utils-0.0.171.dist-info/RECORD,,