--- subprocess-r241.py 2007-08-15 14:54:53.000000000 -0700 +++ subprocess_nogc.py 2007-12-05 09:34:13.000000000 -0800 @@ -228,9 +228,9 @@ ------------------------- output=`dmesg | grep hda` ==> p1 = Popen(["dmesg"], stdout=PIPE) -p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) +p2 = Popen(["grep", "hda"], stdin=p1.stdout) output = p2.communicate()[0] Replacing os.system() @@ -361,8 +361,9 @@ import os import types import traceback +import gc if mswindows: import threading import msvcrt @@ -489,9 +490,8 @@ if bs_buf: result.extend(bs_buf) if needquote: - result.extend(bs_buf) result.append('"') return ''.join(result) @@ -504,11 +504,8 @@ startupinfo=None, creationflags=0): """Create new Popen instance.""" _cleanup() - if not isinstance(bufsize, (int, long)): - raise TypeError("bufsize must be an integer") - if mswindows: if preexec_fn is not None: raise ValueError("preexec_fn is not supported on Windows " "platforms") @@ -917,8 +914,10 @@ self.pid = os.fork() if self.pid == 0: # Child + # Disable gc to avoid bug where gc -> file_dealloc -> write to stderr -> hang. + gc.disable() try: # Close parent's pipe ends if p2cwrite: os.close(p2cwrite) @@ -985,9 +984,8 @@ # Wait for exec to fail or succeed; possibly raising exception data = os.read(errpipe_read, 1048576) # Exceptions limited to 1 MB os.close(errpipe_read) if data != "": - os.waitpid(self.pid, 0) child_exception = pickle.loads(data) raise child_exception