summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-08-04 01:03:50 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-08-04 01:03:50 (GMT)
commit087925028420314d70c25606bdff0b8042138ac7 (patch)
tree1f357d8d6c52477d80b8a10aad5652cf0d797610
parent814820bb28f04e7bf9467cecca8b0f89d8e509a2 (diff)
downloadcpython-087925028420314d70c25606bdff0b8042138ac7.zip
cpython-087925028420314d70c25606bdff0b8042138ac7.tar.gz
cpython-087925028420314d70c25606bdff0b8042138ac7.tar.bz2
issue1606: Add warnings to the subprocess documentation about common pitfalls
of using pipes that cause deadlocks.
-rw-r--r--Doc/library/subprocess.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 5ae6eb0..3458003 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -193,6 +193,10 @@ Instances of the :class:`Popen` class have the following methods:
Wait for child process to terminate. Set and return :attr:`returncode`
attribute.
+ warning:: This will deadlock if the child process generates enough output
+ to a stdout or stderr pipe causing it to block waiting for the OS's pipe
+ buffer to accept more data.
+
.. method:: Popen.communicate(input=None)
@@ -250,18 +254,30 @@ The following attributes are also available:
If the *stdin* argument is ``PIPE``, this attribute is a file object that
provides input to the child process. Otherwise, it is ``None``.
+ warning:: Use :meth:`communicate` rather than .stdin.write() to avoid
+ deadlocks due to any of the other pipe buffers filling up and blocking the
+ child process.
+
.. attribute:: Popen.stdout
If the *stdout* argument is ``PIPE``, this attribute is a file object that
provides output from the child process. Otherwise, it is ``None``.
+ warning:: Use :meth:`communicate` rather than .stdout.read() to avoid
+ deadlocks due to any of the other pipe buffers filling up and blocking the
+ child process.
+
.. attribute:: Popen.stderr
If the *stderr* argument is ``PIPE``, this attribute is file object that
provides error output from the child process. Otherwise, it is ``None``.
+ warning:: Use :meth:`communicate` rather than .stderr.read() to avoid
+ deadlocks due to any of the other pipe buffers filling up and blocking the
+ child process.
+
.. attribute:: Popen.pid