Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bdfd699

Browse files
stainless-app[bot]stainless-bot
authored andcommittedJan 7, 2025
fix(client): only call .close() when needed (#1992)
1 parent 728100c commit bdfd699

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎src/openai/_base_client.py

+6
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ def __init__(self, **kwargs: Any) -> None:
769769

770770
class SyncHttpxClientWrapper(DefaultHttpxClient):
771771
def __del__(self) -> None:
772+
if self.is_closed:
773+
return
774+
772775
try:
773776
self.close()
774777
except Exception:
@@ -1351,6 +1354,9 @@ def __init__(self, **kwargs: Any) -> None:
13511354

13521355
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
13531356
def __del__(self) -> None:
1357+
if self.is_closed:
1358+
return
1359+
13541360
try:
13551361
# TODO(someday): support non asyncio runtimes here
13561362
asyncio.get_running_loop().create_task(self.aclose())

0 commit comments

Comments
 (0)
Please sign in to comment.