Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared data content when used with FastAPI backgroundtasks and client.beta.threads.runs.create_and_poll #1345

Open
1 task done
Robban1980 opened this issue Apr 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Robban1980
Copy link

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

I have a FastAPI API that I have one endpoint in /execute. This endpoint creates a FastAPI backgroundtask to do a call to the assistants API. In here I make a request to client.beta.threads.runs.create_and_poll, there are no issues starting the request and getting the expected outcome. However, if another request comes in to the API, when the first request background task is still waiting for the create_and_poll, both requests will complete at the same time and the result out from create_and_poll will be based on the first request it received.
I am creating the OpenAI client in the backgrountask method to not use a global one.

I am a beginner in python and still trying to learn and understand how things are isolated, could this be a usage error or is there no thread isolation for the client.beta.threads.runs.create_and_poll method?

To Reproduce

Code snippets

No response

OS

Ubuntu

Python version

Python 3.10

Library version

openai 1.20

@Robban1980 Robban1980 added the bug Something isn't working label Apr 19, 2024
@rattrayalex
Copy link
Collaborator

rattrayalex commented Apr 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants