Im using python3 on ubuntu 18. I have a python code to run some ansible playbooks, i want my code to give me some id \ process id of the current runing process and when it is finished.
for example this code :
process = subprocess.Popen(["ansible-playbook", "-i", "hosts", "playbook.yml"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
can this release some process id and also to let me know when this proc id is finished \ closed? I looked for a way with multiprocessing and threads but it seems like it is just does not fit Thanks.
EDIT: i need the subproc ID when it start, not when subproc already done. process.pid gives ID after it is done