多进程BaseManager关闭()需要二十秒
我正在使用BaseManager来和一组工作进程共享一个队列。我调用start()来让管理器在另一个线程中运行。
在shutdown()的说明中提到:“只有在使用start()启动服务器进程后,这个功能才可用。”但是,每次我调用shutdown()时,前台进程都会在管理器进程上阻塞二十秒钟才会终止。如果我不调用shutdown(),前台进程就会立刻退出?
我是不是漏掉了什么?
另外,有没有人知道为什么文档里说:“这可以被多次调用。”?为什么要给管理器进程发送多次关闭信号呢?
1 个回答
1
这个程序设计上会等待20秒。想了解更多信息,请 点击这里。
process.join(timeout=0.2)
if process.is_alive():
util.info('manager still alive')
if hasattr(process, 'terminate'):
util.info('trying to `terminate()` manager process')
process.terminate()
process.join(timeout=0.1)
if process.is_alive():
util.info('manager still alive after terminate')