Silence annoying OpenAI client shutdown error (#4157)
This commit is contained in:
committed by
GitHub
parent
7100b7e004
commit
4ac82ec25b
24
skyvern/forge/forge_openai_client.py
Normal file
24
skyvern/forge/forge_openai_client.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import asyncio
|
||||
|
||||
from openai import DefaultAsyncHttpxClient
|
||||
|
||||
|
||||
class ForgeAsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
|
||||
"""
|
||||
Wrapper around OpenAI's AsyncHttpxClientWrapper to mask teardown races.
|
||||
|
||||
The upstream `__del__` checks `self.is_closed`, but during interpreter
|
||||
shutdown httpx internals may already be None, which raises:
|
||||
|
||||
AttributeError: 'NoneType' object has no attribute 'CLOSED'
|
||||
|
||||
We defensively swallow that destructor error so shutdown logs stay clean.
|
||||
"""
|
||||
|
||||
def __del__(self) -> None:
|
||||
try:
|
||||
if self.is_closed:
|
||||
return
|
||||
asyncio.get_running_loop().create_task(self.aclose())
|
||||
except Exception:
|
||||
pass
|
||||
Reference in New Issue
Block a user