Charles-François Natali <neolo...@free.fr> added the comment: There's just one thing I'm concerned with. People using context managers tend to expect the __exit__ method to perform cleanup actions and release corresponding resources if necessary, for example closing the underlying file or socket. So my guess is that most people won't explicitly wait for the process termination. You can already find such examples inside test_subprocess.py, Lib/ctypes/util.py (to parse ldconfig's output), and even in subprocess' documentation:
""" with Popen(["ifconfig"], stdout=PIPE) as proc: log.write(proc.stdout.read()) """ The problem is that until a child process is wait()ed on or its parent process terminates (so that the child gets re-parented to init), the child remains a zombie/defunct process. So if you have long-running process spawning many subprocesses, you could end up having many zombie processes, potentially filling up your process table at some point. And this really sucks. So I think it could be worth mentioning this somewhere in the documentation (I mean, if we can find find such leaks inside CPython code base, then it's definitely something that should be documented). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12044> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com