Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
seg fault when using async and running openai integration tests with the latest version on windows
running this
python -q -X faulthandler test.py
gets this:
ChatCompletion(id='chatcmpl-8JvRae0P4EOZRkIJuGQQMFBQ6lRpf', choices=[Choice(finish_reason='stop', index=0, message=ChatCompletionMessage(content='Hello! How can I assist you today?', role='a
ssistant', function_call=None, tool_calls=None))], created=1699759738, model='gpt-3.5-turbo-0613', object='chat.completion', system_fingerprint=None, usage=CompletionUsage(completion_tokens=
9, prompt_tokens=18, total_tokens=27))
Windows fatal exception: access violation
Current thread 0x000032c8 (most recent call first):
Garbage-collecting
File "C:\Users\erik\.pyenv\pyenv-win\versions\3.11.6\Lib\asyncio\proactor_events.py", line 82 in __repr__
File "C:\Users\erik\.pyenv\pyenv-win\versions\3.11.6\Lib\asyncio\proactor_events.py", line 116 in __del__
Segmentation fault
i updated to 3.11.6 jut to see if that helped... nope
i don't normally have issues with async code, and i have unit tests and code passing fine. only the openai lib has this issue.
fortunately it only fails at exit, so i can keep on keeping on for now without worrying too much
To Reproduce
using windows pyenv python 3.11.5 or 3.11.6, use the async openai client to make a single chat completion in a pytest test.
it works, but then your program segfaults
all other httpx async/rest/tests all work, even respx live tests, etc.
only when i do the integration test with openai does it fail
Code snippets
example of failure
from openai import AsyncOpenAI
import asyncio
async def x():
model="gpt-3.5-turbo"
client = AsyncOpenAI()
messages = [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello"
},
]
response = await client.chat.completions.create(
model=model,
messages=messages,
max_tokens=500
)
return response
print(asyncio.run(x()))
### OS
windows
### Python version
3.11.5
### Library version
openai==1.2.3
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
seg fault when using async and running openai integration tests with the latest version on windows
running this
gets this:
i updated to 3.11.6 jut to see if that helped... nope
i don't normally have issues with async code, and i have unit tests and code passing fine. only the openai lib has this issue.
fortunately it only fails at exit, so i can keep on keeping on for now without worrying too much
To Reproduce
using windows pyenv python 3.11.5 or 3.11.6, use the async openai client to make a single chat completion in a pytest test.
it works, but then your program segfaults
all other httpx async/rest/tests all work, even respx live tests, etc.
only when i do the integration test with openai does it fail
Code snippets