Re: [问题] socketio & thread

楼主: gn00618777 (非常念旧)   2015-05-17 11:54:59
※ 引述《gn00618777 (非常念旧)》之铭言:
: 我在 flask 框架下使用 sokcetio,以下是草略架构
: server.py:
: from flask import Flask
: from threadin import Thread
: app = Flask(__name__)
: socketio = SocketIO(app)
: def background_thread():
: while True:
: ...
: ...
: @app.route('/')
: def index():
: thread = Thread(target=background_thread)
: tread.start()
: return render_template('receiver.html')
: @socketio.on('connect',namespace='/test')
楼主: gn00618777 (非常念旧)   2015-05-17 12:08:00
OK,测试结果还是有增加,所以 thread 还是没有结束没错,只是有没有办法直接 kill thread 的方法
作者: dritchie (卍~迈斯纳效应~卍)   2015-05-17 21:57:00
Python 原生不提供 terminate thread 的方法
作者: eight0 (欸XD)   2015-05-18 12:30:00
http://x.co/9SsXc 可以 stop/pause/resume,参考看看
楼主: gn00618777 (非常念旧)   2015-05-18 16:16:00
感谢

Links booklink

Contact Us: admin [ a t ] ucptt.com