def run ( context , port ) : global ctx ctx = context app . run ( port = port )
python flask start a thread outside web context
Run the Webserver / SocketIO and app
def run(context, port):
    """ Run the Webserver/SocketIO and app
    """
    global ctx
    ctx = context
    app.run(port=port)