Skip to content

Commit d861708

Browse files
fix(client): close streams without requiring full consumption
1 parent d8ab6cb commit d861708

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/llama_stack_client/_streaming.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ def __stream__(self) -> Iterator[_T]:
6363
for sse in iterator:
6464
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
6565

66-
# Ensure the entire stream is consumed
67-
for _sse in iterator:
68-
...
66+
# As we might not fully consume the response stream, we need to close it explicitly
67+
response.close()
6968

7069
def __enter__(self) -> Self:
7170
return self
@@ -127,9 +126,8 @@ async def __stream__(self) -> AsyncIterator[_T]:
127126
async for sse in iterator:
128127
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
129128

130-
# Ensure the entire stream is consumed
131-
async for _sse in iterator:
132-
...
129+
# As we might not fully consume the response stream, we need to close it explicitly
130+
await response.aclose()
133131

134132
async def __aenter__(self) -> Self:
135133
return self

0 commit comments

Comments
 (0)