From 3d343712c0aa31298e0bd7f4a5766bbd2db1d1dd Mon Sep 17 00:00:00 2001 From: raulblazquezbullon Date: Thu, 12 Mar 2026 18:27:31 +0100 Subject: [PATCH] fix(client): guard against AttributeError in AsyncHttpxClientWrapper.__del__ --- src/openai/_base_client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/openai/_base_client.py b/src/openai/_base_client.py index cf4571bf45..6af17de23f 100644 --- a/src/openai/_base_client.py +++ b/src/openai/_base_client.py @@ -1427,11 +1427,10 @@ 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 + if self.is_closed: + return asyncio.get_running_loop().create_task(self.aclose()) except Exception: pass