Python 3.x 使用子进程popen在长进程中获取pid

Python 3.x 使用子进程popen在长进程中获取pid,python-3.x,popen,pid,Python 3.x,Popen,Pid,我需要Python3.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.c

我需要Python3.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只有在流程完成后才会过帐。但是我需要它,在杀戮的过程中。有办法吗?因为只要subprocess.Popen返回对象,pid就可以使用,无需等待。 是等待进程完成的通信功能