This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients brian.curtin, gregory.p.smith, neologix, pitrou
Date 2011-05-10.16:08:26
SpamBayes Score 8.790304e-09
Marked as misclassified No
Message-id <BANLkTinRDu0_r7fNPT4Aov=GpCVFybm-4A@mail.gmail.com>
In-reply-to <1304994502.26.0.0380016504587.issue12044@psf.upfronthosting.co.za>
Content
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).
History
Date User Action Args
2011-05-10 16:08:27neologixsetrecipients: + neologix, gregory.p.smith, pitrou, brian.curtin
2011-05-10 16:08:26neologixlinkissue12044 messages
2011-05-10 16:08:26neologixcreate