diff --git a/src/openai/_base_client.py b/src/openai/_base_client.py index 17863bc067..a38efed706 100644 --- a/src/openai/_base_client.py +++ b/src/openai/_base_client.py @@ -837,7 +837,9 @@ def __del__(self) -> None: try: self.close() except Exception: - pass + # Suppress destructor cleanup errors; object finalizers should not raise + # during garbage collection or interpreter shutdown. + log.debug("Failed to close sync HTTP client during object finalization", exc_info=True) class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]): @@ -1434,7 +1436,9 @@ def __del__(self) -> None: # TODO(someday): support non asyncio runtimes here asyncio.get_running_loop().create_task(self.aclose()) except Exception: - pass + # Suppress destructor cleanup errors; object finalizers should not raise + # during garbage collection or interpreter shutdown. + log.debug("Failed to close async HTTP client during object finalization", exc_info=True) class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):