Flask APP - ValueError: signal only works in main thread
The problem you are facing has to do with a bug in the Flask-SocketIO package which replaces the flask run
command. Due to this Flask-SocketIO is always used even if you don’t import it. There are several solutions:
- Uninstall Flask-SocketIO
- Do not use
flask run
but run the main file of your program - Disable debugging
- Disable auto loading if debugging required
flask run --no-reload
Reference to the Flask-SocketIO bug: issue 817
I solved the problem thanks to @AkshayKumar007 answer on github. That was the most convenient solution for me.
Hey guys, I was also facing the same problem. So to summarize, if you're using socket-io, don't do flask run. First, add
if __name__ == "__main__": socketio.run(app)
At the end of your application. To run it just do
python3 __init__.py
Hope it helped.