0
I am running a parallel process in python:
process = subprocess.Popen(['python',path, title, uid])
The program takes +- 1 minute to finish and runs normally. The process generates a PID that I can capture: process.pid
. In one example he generated the PID 29058
. I have another program that will handle these PID and verify which ended through the function:
def check_pid(pid):
try:
os.kill(pid, 0)
except OSError:
return False
else:
return True
Which also works normally.
But even though my program I ran on Popen
finish, and I’m sure it happens. The process on Ubuntu still continues running the process, without consuming memory and nothing:
My main program which I call the first command above is a Bottle server which will not finish unless I want it to. When I kill the Bottle server process this process PID 29058
also dies. What I want to know is if there are any parameters that I pass on Popen that make the process die automatically when finished and not stand still like this?
My server cannot wait for this process to finish to continue running, my only control of what is running and check if the PID process is running.
– Vinicius Morais
I increased the response with the "one obvious way" used nowadays for this type of task: using Celery. But the idea of calling the
wait
would be after you detected that the external process has accomplished the task, not while it is processing.– jsbueno