Bladeren bron

Merge pull request #784 from flying1020/master

让 flask 的 web 服务以多线程的方式启动。
walle-web.io 6 jaren geleden
bovenliggende
commit
fda9247822
1 gewijzigde bestanden met toevoegingen van 5 en 1 verwijderingen
  1. 5 1
      walle/app.py

+ 5 - 1
walle/app.py

@@ -6,6 +6,8 @@ gevent.monkey.patch_all()
 import logging
 import sys
 import os
+import threading
+
 from flask import Flask, render_template, current_app
 from flask_restful import Api
 from walle import commands
@@ -187,7 +189,9 @@ def register_socketio(app):
         return app
     socketio.init_app(app, async_mode='gevent')
     socketio.on_namespace(WalleSocketIO(namespace='/walle'))
-    socketio.run(app, debug=app.config.get('DEBUG'), host=app.config.get('HOST'), port=app.config.get('PORT'))
+    socket_args = {"debug": app.config.get('DEBUG'), "host": app.config.get('HOST'), "port": app.config.get('PORT')}
+    socket_thread = threading.Thread(target=socketio.run, name="socket_thread", args=(app, ), kwargs=socket_args)
+    socket_thread.start()
     return app