Message147820
subprocess.Popen.communicate() hangs for daemonized subprocesses that leave a pipe open. The python caller, invoking the daemon subprocess, runs as long as the daemon process. This happens on POSIX platforms with python 2.7 as well as 3.2.
Please find attached a simple python daemon, which leaves stderr pipe open. It runs for 10 sec and then exits.
To reproduce the problem run the following start script:
##################
# startpydaemon.py
import subprocess
cmd = 'python pydaemon.py'
print("Starting daemon that runs for 10 sec")
daemon = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
stdout, stderr = daemon.communicate()
print("Stdout:")
print(stdout)
print("Stderr:")
print(stderr)
##################
Expected Behavior:
------------------
Daemon starter should exit immediately after the daemon process is initialized.
Actual Behavior:
----------------
Daemon starter waits for daemon process to be finished due to left open error pipe.
Workaround:
-----------
One workaround is to not capture output from the left-open pipe. This way. |
|
Date |
User |
Action |
Args |
2011-11-17 20:35:44 | fsteffenhagen | set | recipients:
+ fsteffenhagen |
2011-11-17 20:35:43 | fsteffenhagen | set | messageid: <1321562143.65.0.570707046808.issue13422@psf.upfronthosting.co.za> |
2011-11-17 20:35:43 | fsteffenhagen | link | issue13422 messages |
2011-11-17 20:35:42 | fsteffenhagen | create | |
|