mirror of
https://github.com/anomalyco/opencode-sdk-python.git
synced 2026-05-17 12:42:25 +00:00
fix(client): close streams without requiring full consumption
This commit is contained in:
parent
7175e3b026
commit
14ee6073a4
1 changed files with 4 additions and 6 deletions
|
|
@ -57,9 +57,8 @@ class Stream(Generic[_T]):
|
|||
for sse in iterator:
|
||||
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
||||
|
||||
# Ensure the entire stream is consumed
|
||||
for _sse in iterator:
|
||||
...
|
||||
# As we might not fully consume the response stream, we need to close it explicitly
|
||||
response.close()
|
||||
|
||||
def __enter__(self) -> Self:
|
||||
return self
|
||||
|
|
@ -121,9 +120,8 @@ class AsyncStream(Generic[_T]):
|
|||
async for sse in iterator:
|
||||
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
||||
|
||||
# Ensure the entire stream is consumed
|
||||
async for _sse in iterator:
|
||||
...
|
||||
# As we might not fully consume the response stream, we need to close it explicitly
|
||||
await response.aclose()
|
||||
|
||||
async def __aenter__(self) -> Self:
|
||||
return self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue