title: How to run Flask SocketIO in a thread?
body: <p>I'm trying to run Flask SocketIO in thread using Python 3 and I cannot get it to work.</p>
  
  <p>My code will not continue in my while loop.</p>
  
  <p>How can I run it in thread?</p>
  
  <pre><code>import threading
  from flask import Flask, render_template, request, redirect, url_for
  from flask_socketio import SocketIO
  
  app = Flask(__name__)
  app.config['SECRET_KEY'] = 'secret!'
  
  
  #turn the flask app into a socketio app
  socketio = SocketIO(app)
  
  
  @app.route("/")
  def index():
     return render_template('index.html', **templateData)
  
  if __name__ == "__main__":
     threading.Thread(target=socketio.run(app),kwargs=dict(debug=False, use_reloader=False,host='0.0.0.0', port=5000)).start()
     sleep(2)
  
     while True:
         try:
             Print("Hello I'm in a while loop")
  
         except KeyboardInterrupt:
             sys.exit()
  </code></pre>