We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 157c39b commit 3908ac8Copy full SHA for 3908ac8
1 file changed
python_utils/generators.py
@@ -1,3 +1,4 @@
1
+import asyncio
2
import time
3
4
import python_utils
@@ -26,8 +27,13 @@ async def abatcher(
26
27
28
while True:
29
try:
- item = await generator.__anext__()
30
- except StopAsyncIteration:
+ if interval_s:
31
+ item = await asyncio.wait_for(
32
+ generator.__anext__(), interval_s
33
+ )
34
+ else:
35
+ item = await generator.__anext__()
36
+ except (StopAsyncIteration, asyncio.TimeoutError):
37
if batch:
38
yield batch
39
break
0 commit comments