Replies: 1 comment 6 replies
-
I think you are confusing threads with processes here. You are running 4 processes, so your global variables will be created four times. Change the |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have been following this guide and modified the code to conform with my project:
https://blog.miguelgrinberg.com/post/add-a-websocket-route-to-your-flask-2-x-application
My goal is to create a web app where you can control a quadcopter-drone with the Crazyswarm library.
Here is my app.py
index.html:
The issue lies within using this command
$ gunicorn -b 0.0.0.0:5000 --workers 4 --threads 100 app:app
As multiple threads are run, this line in app.py is called multiple times:
cf = swarm.allcfs.crazyflies[0]
This creates a conflict, as this drone already has been instantiated in a different thread.
This leads to my program terminating.
If I only use one thread, the program will die rather quickly so I need the threads.
Is there a solution for only using on object across all threads? Because clearly, each thread instantiates that object..
I appreciate all answers, please ask for more details if needed. Sorry if I am being unclear.
Warm regards,
Noah
Beta Was this translation helpful? Give feedback.
All reactions