terminate/kill 和获取 tornado.subprocess 的 return 代码的正确方法是什么?
Whats the right way to terminate/kill and get return code for a tornado.subprocess?
我能够启动龙卷风子进程
sp = tornado.process.subprocess(..)
但希望有能力在某些事件中杀死同样的人。
通过仔细阅读代码,我可以设法做到这一点的唯一方法是使用 tornado 子进程对象的 'proc' 属性的 terminate() 方法,因为 tornado 子进程构造函数初始化 'proc' 属性到 Subprocess Popen。所以:
sp.proc.terminate()
似乎有效。但是我不确定这是最好的方法
还有如何获得return代码?尝试使用
sp.proc.returncode
好像是returnNone
是的,sp.proc.terminate()
是目前最好的方式;我们不直接公开终止方法或进程 ID。
要获得 return 代码,您必须使用 sp.wait_for_exit()
或 sp.set_exit_callback()
。
我能够启动龙卷风子进程
sp = tornado.process.subprocess(..)
但希望有能力在某些事件中杀死同样的人。
通过仔细阅读代码,我可以设法做到这一点的唯一方法是使用 tornado 子进程对象的 'proc' 属性的 terminate() 方法,因为 tornado 子进程构造函数初始化 'proc' 属性到 Subprocess Popen。所以:
sp.proc.terminate()
似乎有效。但是我不确定这是最好的方法
还有如何获得return代码?尝试使用
sp.proc.returncode
好像是returnNone
是的,sp.proc.terminate()
是目前最好的方式;我们不直接公开终止方法或进程 ID。
要获得 return 代码,您必须使用 sp.wait_for_exit()
或 sp.set_exit_callback()
。