subprocess.Popen calling httpd reload never finishes
ringemup at gmail.com
Tue Aug 17 21:55:21 CEST 2010
Hi folks --
I have a Python script running under Apache/mod_wsgi that needs to
reload Apache configs as part of its operation. The script continues
to execute after the subprocess.Popen call. The communicate() method
returns the correct text ("Reloading httpd: [ OK ]"), and I get a
returncode of 0. But the python script (Django) that calls Popen
never seems to complete (by returning an HTTP response.
Any other Popen call I've tried exits properly. Here's some sample
args = ['sudo /etc/init.d/httpd reload']
proc = subprocess.Popen(args, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
(stdout_txt, stderr_txt) = proc.communicate("")
logging.debug('%d %s<hr />%s' % (proc.returncode, stdout_txt,
The logging statements are output, but the script doesn't exit. If
you substitute "sudo ls -l" or "sudo /etc/init.d/httpd configtest" for
"sudo /etc/init.d/httpd reload", the exits properly.
Any idea what I might be doing wrong?
More information about the Python-list