Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions runpod/endpoint/asyncio/asyncio_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Module for running endpoints asynchronously. """
"""Module for running endpoints asynchronously."""

# pylint: disable=too-few-public-methods,R0801

Expand Down Expand Up @@ -89,9 +89,14 @@ async def stream(self) -> Any:
while True:
await asyncio.sleep(1)
stream_partial = await self._fetch_job(source="stream")
if stream_partial["status"] not in FINAL_STATES:
if (
stream_partial["status"] not in FINAL_STATES
or len(stream_partial.get("stream", [])) > 0
):
for chunk in stream_partial.get("stream", []):
yield chunk["output"]
elif stream_partial["status"] in FINAL_STATES:
break

async def cancel(self) -> dict:
"""Cancels current job
Expand Down
4 changes: 1 addition & 3 deletions tests/test_endpoint/test_asyncio_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Unit tests for the asyncio_runner module. """
"""Unit tests for the asyncio_runner module."""

# pylint: disable=too-few-public-methods

Expand Down Expand Up @@ -114,8 +114,6 @@ async def json_side_effect():
outputs = []
async for stream_output in job.stream():
outputs.append(stream_output)
if not responses: # Break the loop when responses are exhausted
break

assert outputs == ["OUTPUT1", "OUTPUT2"]

Expand Down
Loading