Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): only call .close() when needed (#1992)
Browse files Browse the repository at this point in the history
stainless-app[bot] authored and stainless-bot committed Jan 7, 2025
1 parent 728100c commit bdfd699
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/openai/_base_client.py
Original file line number Diff line number Diff line change
@@ -769,6 +769,9 @@ def __init__(self, **kwargs: Any) -> None:

class SyncHttpxClientWrapper(DefaultHttpxClient):
def __del__(self) -> None:
if self.is_closed:
return

try:
self.close()
except Exception:
@@ -1351,6 +1354,9 @@ def __init__(self, **kwargs: Any) -> None:

class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
def __del__(self) -> None:
if self.is_closed:
return

try:
# TODO(someday): support non asyncio runtimes here
asyncio.get_running_loop().create_task(self.aclose())

0 comments on commit bdfd699

Please sign in to comment.