Closed
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Our retry logic was successful before migration to openai v1.0.0. However, now the retry fails as described below.
After a call to openai's API chat.completions.create
fails with a Connection Error, our code will catch the exception and retry. However, the retry fails with the following error:
File "<our code>.py", line xxx, in <our_method1>
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/nest_asyncio.py", line 35, in run
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/nest_asyncio.py", line 90, in run_until_complete
File "/opt/conda/envs/pbap_prompt/lib/python3.10/asyncio/futures.py", line 201, in result
File "/opt/conda/envs/pbap_prompt/lib/python3.10/asyncio/tasks.py", line 232, in __step
File "<our code>.py", line xxx, in <our_method2>
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/openai/_client.py", line 317, in __init__
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/openai/_base_client.py", line 1190, in __init__
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_client.py", line 1397, in __init__
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_client.py", line 1445, in _init_transport
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_transports/default.py", line 272, in __init__
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_config.py", line 51, in create_ssl_context
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_config.py", line 75, in __init__
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_config.py", line 87, in load_ssl_context
File "/opt/conda/envs/pbap_prompt/lib/python3.10/site-packages/httpx/_config.py", line 145, in load_ssl_context_verify
OSError: [Errno 24] Too many open files
Here is a snippet of our methods:
method1:
try:
outputs = asyncio.run(
method2
)
method2:
AsyncOpenAI(
api_key=xxx,
organization=xxx,
max_retries=0,
).chat.completions.create(
model=model,
messages=input_data,
max_tokens=max_new_tokens,
temperature=temperature,
timeout=timeout,
)
)
To Reproduce
- create openai async client and call
chat.completions.create
- openai returns error such as
Connection Error
- catch error and create new openai async client and call
chat.completions.create
again - receive error
OSError: [Errno 24] Too many open files
Code snippets
See above
OS
Unix Ubuntu
Python version
Python v3.10.0
Library version
openai 1.3.5