Skip to content

Commit

Permalink
fix(client): only call .close() when needed (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 8, 2025
1 parent 728100c commit bd49dd1
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
Expand Up @@ -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:
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit bd49dd1

Please sign in to comment.