Skip to content

Commit ce71ef5

Browse files
fix(client): close streams without requiring full consumption
1 parent 6efc023 commit ce71ef5

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/runloop_api_client/_streaming.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ def __stream__(self) -> Iterator[_T]:
8787

8888
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
8989

90-
# Ensure the entire stream is consumed
91-
for _sse in iterator:
92-
...
90+
# As we might not fully consume the response stream, we need to close it explicitly
91+
response.close()
9392

9493
def __enter__(self) -> Self:
9594
return self
@@ -162,9 +161,8 @@ async def __stream__(self) -> AsyncIterator[_T]:
162161

163162
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
164163

165-
# Ensure the entire stream is consumed
166-
async for _sse in iterator:
167-
...
164+
# As we might not fully consume the response stream, we need to close it explicitly
165+
await response.aclose()
168166

169167
async def __aenter__(self) -> Self:
170168
return self

0 commit comments

Comments
 (0)