- Issue #1336: fix a race condition in subprocess.Popen if the garbage
collector kicked in at the wrong time that would cause the process
to hang when the child wrote to stderr.
import os
import types
import traceback
+import gc
# Exception classes used by this module.
class CalledProcessError(Exception):
errpipe_read, errpipe_write = os.pipe()
self._set_cloexec_flag(errpipe_write)
- self.pid = os.fork()
+ gc_was_enabled = gc.isenabled()
+ # Disable gc to avoid bug where gc -> file_dealloc ->
+ # write to stderr -> hang. http://bugs.python.org/issue1336
+ gc.disable()
+ try:
+ self.pid = os.fork()
+ except:
+ if gc_was_enabled:
+ gc.enable()
+ raise
self._child_created = True
if self.pid == 0:
# Child
os._exit(255)
# Parent
+ if gc_was_enabled:
+ gc.enable()
os.close(errpipe_write)
if p2cread and p2cwrite:
os.close(p2cread)
Library
-------
+- Issue #1336: fix a race condition in subprocess.Popen if the garbage
+ collector kicked in at the wrong time that would cause the process
+ to hang when the child wrote to stderr.
+
- Bug #1687: Fixed plistlib.py restricts <integer> to Python int when writing.
- Issue #1182: many arithmetic bugs in the decimal module have been