Skip to content

Commit

Permalink
fix(client): only call .close() when needed (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 7, 2025
1 parent 10436fd commit 679e438
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,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 @@ -1349,6 +1352,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 679e438

Please sign in to comment.