diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 82487aa1..3293542f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.402.0" + ".": "0.402.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2724b8b8..f8f49813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.402.1 (2025-11-27) + +Full Changelog: [v0.402.0...v0.402.1](https://github.com/Increase/increase-python/compare/v0.402.0...v0.402.1) + +### Bug Fixes + +* ensure streams are always closed ([acccbef](https://github.com/Increase/increase-python/commit/acccbeff71f9a2de64a879a19ccfe797b0a717c9)) + ## 0.402.0 (2025-11-26) Full Changelog: [v0.401.0...v0.402.0](https://github.com/Increase/increase-python/compare/v0.401.0...v0.402.0) diff --git a/pyproject.toml b/pyproject.toml index 0807076a..53ef7b40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "increase" -version = "0.402.0" +version = "0.402.1" description = "The official Python library for the increase API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/increase/_streaming.py b/src/increase/_streaming.py index 31a76968..48bbc2c5 100644 --- a/src/increase/_streaming.py +++ b/src/increase/_streaming.py @@ -54,11 +54,12 @@ def __stream__(self) -> Iterator[_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 @@ async def __stream__(self) -> AsyncIterator[_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 diff --git a/src/increase/_version.py b/src/increase/_version.py index 147dd81e..181d08f6 100644 --- a/src/increase/_version.py +++ b/src/increase/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "increase" -__version__ = "0.402.0" # x-release-please-version +__version__ = "0.402.1" # x-release-please-version