Jer*_*rub 26
理想情况下,您不会将变量设置为值并停止反应堆,您可以调用reactor.stop().有时你不在主线程中,这是不允许的,所以你可能需要打电话reactor.callFromThread.以下是三个工作示例:
# in the main thread:
reactor.stop()
# in a non-main thread:
reactor.callFromThread(reactor.stop)
# A looping call that will stop the reactor on a variable being set,
# checking every 60 seconds.
from twisted.internet import task
def check_stop_flag():
if some_flag:
reactor.stop()
lc = task.LoopingCall(check_stop_flag)
lc.start(60)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15051 次 |
| 最近记录: |