chore(internal): codegen related update

This commit is contained in:
stainless-app[bot] 2025-11-28 03:09:11 +00:00
parent 2f2c394c71
commit 9022bea168
4 changed files with 20 additions and 16 deletions

View file

@ -54,11 +54,12 @@ class Stream(Generic[_T]):
process_data = self._client._process_response_data
iterator = self._iter_events()
for sse in iterator:
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
# As we might not fully consume the response stream, we need to close it explicitly
response.close()
try:
for sse in iterator:
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
finally:
# Ensure the response is closed even if the consumer doesn't read all data
response.close()
def __enter__(self) -> Self:
return self
@ -117,11 +118,12 @@ class AsyncStream(Generic[_T]):
process_data = self._client._process_response_data
iterator = self._iter_events()
async for sse in iterator:
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
# As we might not fully consume the response stream, we need to close it explicitly
await response.aclose()
try:
async for sse in iterator:
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
finally:
# Ensure the response is closed even if the consumer doesn't read all data
await response.aclose()
async def __aenter__(self) -> Self:
return self