mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
don't use subprocess.call with PIPEs as the child can fill the pipe buf and
deadlock. add a warning to subprocess docs about this, similar to Popen.wait's. refs http://bugs.jython.org/issue1351
This commit is contained in:
parent
9b6f13ee82
commit
739aa36818
2 changed files with 14 additions and 2 deletions
|
|
@ -157,6 +157,12 @@ This module also defines two shortcut functions:
|
||||||
|
|
||||||
retcode = call(["ls", "-l"])
|
retcode = call(["ls", "-l"])
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
Like :meth:`Popen.wait`, this will deadlock if the child process
|
||||||
|
generates enough output to a stdout or stderr pipe such that it blocks
|
||||||
|
waiting for the OS pipe buffer to accept more data.
|
||||||
|
|
||||||
|
|
||||||
.. function:: check_call(*popenargs, **kwargs)
|
.. function:: check_call(*popenargs, **kwargs)
|
||||||
|
|
||||||
|
|
@ -171,6 +177,10 @@ This module also defines two shortcut functions:
|
||||||
|
|
||||||
.. versionadded:: 2.5
|
.. versionadded:: 2.5
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
See the warning for :func:`call`.
|
||||||
|
|
||||||
|
|
||||||
.. function:: check_output(*popenargs, **kwargs)
|
.. function:: check_output(*popenargs, **kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
# All tests are executed with environment variables ignored
|
# All tests are executed with environment variables ignored
|
||||||
# See test_cmd_line_script.py for testing of script execution
|
# See test_cmd_line_script.py for testing of script execution
|
||||||
|
|
||||||
|
import os
|
||||||
import test.test_support, unittest
|
import test.test_support, unittest
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
@ -29,8 +30,9 @@ class CmdLineTest(unittest.TestCase):
|
||||||
def exit_code(self, *args):
|
def exit_code(self, *args):
|
||||||
cmd_line = [sys.executable, '-E']
|
cmd_line = [sys.executable, '-E']
|
||||||
cmd_line.extend(args)
|
cmd_line.extend(args)
|
||||||
return subprocess.call(cmd_line, stdout=subprocess.PIPE,
|
with open(os.devnull, 'w') as devnull:
|
||||||
stderr=subprocess.PIPE)
|
return subprocess.call(cmd_line, stdout=devnull,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
def test_directories(self):
|
def test_directories(self):
|
||||||
self.assertNotEqual(self.exit_code('.'), 0)
|
self.assertNotEqual(self.exit_code('.'), 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue