New submission from juj:

On Windows, write

a.py:

import subprocess

def ccall(cmdline, stdout, stderr):
  proc = subprocess.Popen(['python', 'b.py'], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
  proc.communicate()
  if proc.returncode != 0: raise subprocess.CalledProcessError(proc.returncode, 
cmdline)
  return 0

# To fix subprocess.check_call, uncomment the following, which is functionally 
equivalent:
# subprocess.check_call = ccall

subprocess.check_call(['python', 'b.py'], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
print 'Finished!'

Then write b.py:

import sys

str = 'aaa'
for i in range(0,16): str = str + str
for i in range(0,2): print >> sys.stderr, str
for i in range(0,2): print str

Finally, run 'python a.py'. The application will hang. Uncomment the specicied 
line to fix the execution.

This is a documented failure on the python subprocess page, but why not just 
fix it up directly in python itself?

One can think that modifying stdout or stderr is not the intent for 
subprocess.check_call, but python certainly should not hang because of that.

----------
components: Library (Lib)
messages: 227095
nosy: juj
priority: normal
severity: normal
status: open
title: subprocess.check_call hangs on large PIPEd data.
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22442>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to