caffeinism-utils 0.0.170__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
CHANGED
|
@@ -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
|
|
@@ -26,20 +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
35
|
|
|
36
|
-
def
|
|
36
|
+
async def close(self):
|
|
37
|
+
await self.queue.put(self._CLOSE)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class StreamQueue(BaseStreamQueue):
|
|
41
|
+
queue: asyncio.Queue[T]
|
|
42
|
+
|
|
43
|
+
def put(self, data: T) -> None:
|
|
44
|
+
return self.queue.put(data)
|
|
45
|
+
|
|
46
|
+
async def __aiter__(self) -> AsyncGenerator[T]:
|
|
47
|
+
while (it := await self.queue.get()) is not self._CLOSE:
|
|
48
|
+
yield it
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class StreamIteratorQueue(BaseStreamQueue):
|
|
52
|
+
queue: asyncio.Queue[AsyncIterable[T]]
|
|
53
|
+
|
|
54
|
+
def put(self, data: AsyncIterable[T]) -> None:
|
|
37
55
|
return self.queue.put(data)
|
|
38
56
|
|
|
39
57
|
async def __aiter__(self) -> AsyncGenerator[T]:
|
|
40
|
-
while (iterator := await self.queue.get()) is not
|
|
58
|
+
while (iterator := await self.queue.get()) is not self._CLOSE:
|
|
41
59
|
async for it in iterator:
|
|
42
60
|
yield it
|
|
43
|
-
|
|
44
|
-
async def close(self):
|
|
45
|
-
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
|