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:

  1. Uninstall Flask-SocketIO
  2. Do not use flask run but run the main file of your program
  3. Disable debugging
  4. 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__":

At the end of your application. To run it just do

python3 __init__.py

Hope it helped.