[issue15408] os.fork/os.popen behaviour change between 2.7 and 3.2

Richard Oudkerk report at bugs.python.org
Mon Jul 23 10:09:50 CEST 2012


Richard Oudkerk <shibturn at gmail.com> added the comment:

In Python 2.x, when the file object returned by popen() is garbage collected the process is automatically waited on, collecting the pid of the process.

In Python 3.x a wrapper object is used whose close method wait on the pid.  This close method is *not* invoked when the wrapper is garbage collected.  However, the set of dead pids cannot accumulate since dead pids get collected whenever os.popen()/subprocess.Popen() is used.

The old behaviour is only an advantage in a refcounted implementation of Python like CPython.  I am not sure that "fixing" the current behaviour is necessary.

Simply adding to the wrapper class a __del__() method which invokes close() will not work.  (One could instead use a weakref callback, but that is non-trivial.)

----------
versions: +Python 3.3 -Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15408>
_______________________________________


More information about the Python-bugs-list mailing list