我需要使用在Python 3.5.2中使用Popen运行的进程的PID。
有这个:
with open(info['stdout_file'], 'w') as logfile:
prcs = sp.Popen(split,
stdout=logfile,
stderr=logfile,
cwd=info['runfolder'])
streams = prcs.communicate()
out, err = streams
post = {'pid': prcs.pid}
r = requests.post('https://.../receive_status.php', data=post)
仅在过程完成后才发布过程的PID。但是我需要在过程中能够杀死它。有什么办法吗?因为杀死
该pid可以在子进程中使用。Popen返回对象,无需等待。是等待过程完成的通讯功能。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句