[Python-checkins] r60114 - in python/branches/release24-maint: Lib/subprocess.py Misc/NEWS
gregory.p.smith
python-checkins at python.org
Sat Jan 19 23:35:09 CET 2008
Author: gregory.p.smith
Date: Sat Jan 19 23:35:09 2008
New Revision: 60114
Modified:
python/branches/release24-maint/Lib/subprocess.py
python/branches/release24-maint/Misc/NEWS
Log:
Backport r60104 + r60111 from trunk.
- 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.
Modified: python/branches/release24-maint/Lib/subprocess.py
==============================================================================
--- python/branches/release24-maint/Lib/subprocess.py (original)
+++ python/branches/release24-maint/Lib/subprocess.py Sat Jan 19 23:35:09 2008
@@ -346,6 +346,7 @@
import os
import types
import traceback
+import gc
if mswindows:
import threading
@@ -899,7 +900,16 @@
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
if self.pid == 0:
# Child
try:
@@ -958,6 +968,8 @@
os._exit(255)
# Parent
+ if gc_was_enabled:
+ gc.enable()
os.close(errpipe_write)
if p2cread and p2cwrite:
os.close(p2cread)
Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS (original)
+++ python/branches/release24-maint/Misc/NEWS Sat Jan 19 23:35:09 2008
@@ -26,6 +26,10 @@
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 #1728403: Fix a bug that CJKCodecs StreamReader hangs when it
reads a file that ends with incomplete sequence and sizehint argument
for .read() is specified.
More information about the Python-checkins
mailing list