caffeinism-utils 0.0.171__py3-none-any.whl → 0.0.172__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.
- caffeinism_utils/aiteration.py +14 -14
- {caffeinism_utils-0.0.171.dist-info → caffeinism_utils-0.0.172.dist-info}/METADATA +1 -1
- {caffeinism_utils-0.0.171.dist-info → caffeinism_utils-0.0.172.dist-info}/RECORD +4 -4
- {caffeinism_utils-0.0.171.dist-info → caffeinism_utils-0.0.172.dist-info}/WHEEL +0 -0
caffeinism_utils/aiteration.py
CHANGED
|
@@ -26,35 +26,35 @@ async def rate_limit_iterator(aiterator, iters_per_second):
|
|
|
26
26
|
|
|
27
27
|
T = TypeVar("T")
|
|
28
28
|
|
|
29
|
-
__CLOSE = object()
|
|
30
29
|
|
|
30
|
+
class BaseStreamQueue(Generic[T]):
|
|
31
|
+
_CLOSE = object()
|
|
31
32
|
|
|
32
|
-
class StreamQueue(Generic[T]):
|
|
33
33
|
def __init__(self):
|
|
34
|
-
self.queue = asyncio.Queue
|
|
34
|
+
self.queue = asyncio.Queue()
|
|
35
|
+
|
|
36
|
+
async def close(self):
|
|
37
|
+
await self.queue.put(self._CLOSE)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class StreamQueue(BaseStreamQueue):
|
|
41
|
+
queue: asyncio.Queue[T]
|
|
35
42
|
|
|
36
43
|
def put(self, data: T) -> None:
|
|
37
44
|
return self.queue.put(data)
|
|
38
45
|
|
|
39
46
|
async def __aiter__(self) -> AsyncGenerator[T]:
|
|
40
|
-
while (it := await self.queue.get()) is not
|
|
47
|
+
while (it := await self.queue.get()) is not self._CLOSE:
|
|
41
48
|
yield it
|
|
42
49
|
|
|
43
|
-
async def close(self):
|
|
44
|
-
await self.queue.put(__CLOSE)
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def __init__(self):
|
|
49
|
-
self.queue = asyncio.Queue[AsyncIterable[T]]()
|
|
51
|
+
class StreamIteratorQueue(BaseStreamQueue):
|
|
52
|
+
queue: asyncio.Queue[AsyncIterable[T]]
|
|
50
53
|
|
|
51
54
|
def put(self, data: AsyncIterable[T]) -> None:
|
|
52
55
|
return self.queue.put(data)
|
|
53
56
|
|
|
54
57
|
async def __aiter__(self) -> AsyncGenerator[T]:
|
|
55
|
-
while (iterator := await self.queue.get()) is not
|
|
58
|
+
while (iterator := await self.queue.get()) is not self._CLOSE:
|
|
56
59
|
async for it in iterator:
|
|
57
60
|
yield it
|
|
58
|
-
|
|
59
|
-
async def close(self):
|
|
60
|
-
await self.queue.put(__CLOSE)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
caffeinism_utils/__init__.py,sha256=MER0q-NVosxQWibvx3a3bKwxRWGVXWeso9-qaU6oH_E,43
|
|
2
|
-
caffeinism_utils/aiteration.py,sha256=
|
|
2
|
+
caffeinism_utils/aiteration.py,sha256=0WDoAcx_2veSfVTgtT-v-aPrbNwgyd6WkWb3lJGcZV0,1542
|
|
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.
|
|
15
|
-
caffeinism_utils-0.0.
|
|
16
|
-
caffeinism_utils-0.0.
|
|
14
|
+
caffeinism_utils-0.0.172.dist-info/METADATA,sha256=gZG3t5ptRz5QHXLCa1AbD7wRnqP0Y1TvO6kR2LvhBmc,899
|
|
15
|
+
caffeinism_utils-0.0.172.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
16
|
+
caffeinism_utils-0.0.172.dist-info/RECORD,,
|
|
File without changes
|