New submission from Felix Steffenhagen <fe...@sutus.com>: 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. ---------- components: Library (Lib) files: pydaemon.py messages: 147820 nosy: fsteffenhagen priority: normal severity: normal status: open title: Subprocess: children hang due to open pipes versions: Python 2.6, Python 3.2 Added file: http://bugs.python.org/file23719/pydaemon.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13422> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com