I have an issue using subprocess.call when calling scripts which in turn run background processes.
I am calling a bash script from a python script. python 2.7.3.
#!/bin/python
from subprocess import call
.
.
call(["run_exp",file_name])
print "exp complete!"
.
.
run_exp
is a bash script which runs a process in the background.
#!/bin/bash
.
.
run_task auto_output 2>/dev/null &
.
.
echo "run_exp finished!"
The run task
command is another bash script. This is always completed by the time run_exp
has finished.
Running run_exp
from command line I see expected behaviour and all processes finish completed.
An issue arises when i call the run_exp
command using python call
. When using call
I see the output "run_exp finished!" but never "exp complete!". If I remove the run_task
operation (and associated code with its operation in run_exp
) from run_exp
, the call
command runs to completion as expected. This leads me to believe there is an issue using call
when the script called runs processes in the background.
Can anyone shed any light on why this might occur. Thanks!