File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
- """ Module for running endpoints asynchronously. """
1
+ """Module for running endpoints asynchronously."""
2
2
3
3
# pylint: disable=too-few-public-methods,R0801
4
4
@@ -89,9 +89,14 @@ async def stream(self) -> Any:
89
89
while True :
90
90
await asyncio .sleep (1 )
91
91
stream_partial = await self ._fetch_job (source = "stream" )
92
- if stream_partial ["status" ] not in FINAL_STATES :
92
+ if (
93
+ stream_partial ["status" ] not in FINAL_STATES
94
+ or len (stream_partial .get ("stream" , [])) > 0
95
+ ):
93
96
for chunk in stream_partial .get ("stream" , []):
94
97
yield chunk ["output" ]
98
+ elif stream_partial ["status" ] in FINAL_STATES :
99
+ break
95
100
96
101
async def cancel (self ) -> dict :
97
102
"""Cancels current job
Original file line number Diff line number Diff line change 1
- """ Unit tests for the asyncio_runner module. """
1
+ """Unit tests for the asyncio_runner module."""
2
2
3
3
# pylint: disable=too-few-public-methods
4
4
@@ -114,8 +114,6 @@ async def json_side_effect():
114
114
outputs = []
115
115
async for stream_output in job .stream ():
116
116
outputs .append (stream_output )
117
- if not responses : # Break the loop when responses are exhausted
118
- break
119
117
120
118
assert outputs == ["OUTPUT1" , "OUTPUT2" ]
121
119
You can’t perform that action at this time.
0 commit comments