cpython: c45b124e9af4 (original) (raw)
Mercurial > cpython
changeset 89964:c45b124e9af4
(Merge 3.4) Issue #21006: asyncio doc: reorganize subprocess doc [#21006]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Tue, 25 Mar 2014 09:40:39 +0100 |
parents | 9f7345e23b32(current diff)dd2c7cca5980(diff) |
children | 1d523b48efa3 |
files | |
diffstat | 2 files changed, 94 insertions(+), 84 deletions(-)[+] [-] Doc/library/asyncio-eventloop.rst 84 Doc/library/asyncio-subprocess.rst 94 |
line wrap: on
line diff
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -450,84 +450,8 @@ Resolve host name
:meth:socket.getnameinfo
function but non-blocking.
-Running subprocesses
---------------------
-
-Run subprocesses asynchronously using the :mod:subprocess
module.
-
-.. note::
-
- On Windows, the default event loop uses
- :class:
selectors.SelectSelector
which only supports sockets. The - :class:
ProactorEventLoop
should be used to support subprocesses. -
- On Mac OS X older than 10.9 (Mavericks), :class:
selectors.KqueueSelector
- does not support character devices like PTY, whereas it is used by the
- default event loop. The :class:
SelectorEventLoop
can be used with - :class:
SelectSelector
or :class:PollSelector
to handle character devices - on Mac OS X 10.6 (Snow Leopard) and later. -
-.. method:: BaseEventLoop.subprocess_exec(protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) -
- Create a subprocess from one or more string arguments, where the first string
- specifies the program to execute, and the remaining strings specify the
- program's arguments. (Thus, together the string arguments form the
sys.argv
value of the program, assuming it is a Python script.) This is- similar to the standard library :class:
subprocess.Popen
class called with - shell=False and the list of strings passed as the first argument;
- however, where :class:
~subprocess.Popen
takes a single argument which is - list of strings, :func:
subprocess_exec
takes multiple string arguments. - - Other parameters: -
to the subprocess's standard input stream using[](#l1.40)
:meth:`~BaseEventLoop.connect_write_pipe`, or the constant[](#l1.41)
:const:`subprocess.PIPE` (the default). By default a new pipe will be[](#l1.42)
created and connected.[](#l1.43)
to the subprocess's standard output stream using[](#l1.46)
:meth:`~BaseEventLoop.connect_read_pipe`, or the constant[](#l1.47)
:const:`subprocess.PIPE` (the default). By default a new pipe will be[](#l1.48)
created and connected.[](#l1.49)
to the subprocess's standard error stream using[](#l1.52)
:meth:`~BaseEventLoop.connect_read_pipe`, or one of the constants[](#l1.53)
:const:`subprocess.PIPE` (the default) or :const:`subprocess.STDOUT`.[](#l1.54)
By default a new pipe will be created and connected. When[](#l1.55)
:const:`subprocess.STDOUT` is specified, the subprocess's standard error[](#l1.56)
stream will be connected to the same pipe as the standard output stream.[](#l1.57)
without interpretation, except for *bufsize*, *universal_newlines* and[](#l1.60)
*shell*, which should not be specified at all.[](#l1.61)
- Returns a pair of
(transport, protocol)
, where transport is an - instance of :class:
BaseSubprocessTransport
. - - This method is a :ref:
coroutine <coroutine>
. - - See the constructor of the :class:
subprocess.Popen
class for parameters. -
-.. method:: BaseEventLoop.subprocess_shell(protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) -
- Create a subprocess from cmd, which is a string using the platform's
- "shell" syntax. This is similar to the standard library
- :class:
subprocess.Popen
class called withshell=True
. - - See :meth:
~BaseEventLoop.subprocess_exec
for more details about - the remaining arguments. -
- Returns a pair of
(transport, protocol)
, where transport is an - instance of :class:
BaseSubprocessTransport
. - - This method is a :ref:
coroutine <coroutine>
. - - See the constructor of the :class:
subprocess.Popen
class for parameters. +Connect pipes +-------------
.. method:: BaseEventLoop.connect_read_pipe(protocol_factory, pipe) @@ -553,8 +477,8 @@ Run subprocesses asynchronously using th .. seealso::
--- a/Doc/library/asyncio-subprocess.rst
+++ b/Doc/library/asyncio-subprocess.rst
@@ -3,29 +3,115 @@
Subprocess
==========
-Create a subprocess
--------------------
+Operating system support
+------------------------
+
+On Windows, the default event loop uses :class:selectors.SelectSelector
+which only supports sockets. The :class:ProactorEventLoop
should be used to
+support subprocesses.
+
+On Mac OS X older than 10.9 (Mavericks), :class:selectors.KqueueSelector
+does not support character devices like PTY, whereas it is used by the
+default event loop. The :class:SelectorEventLoop
can be used with
+:class:SelectSelector
or :class:PollSelector
to handle character
+devices on Mac OS X 10.6 (Snow Leopard) and later.
+
+
+Create a subprocess: high-level API using Process
+-------------------------------------------------
.. function:: create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None, loop=None, limit=None, **kwds)
Run the shell command cmd given as a string. Return a :class:~asyncio.subprocess.Process
instance.
- The optional limit parameter sets the buffer limit passed to the
- :class:
StreamReader
. + This function is a :ref:coroutine <coroutine>
.
.. function:: create_subprocess_exec(*args, stdin=None, stdout=None, stderr=None, loop=None, limit=None, **kwds)
Create a subprocess. Return a :class:~asyncio.subprocess.Process
instance.
- The optional limit parameter sets the buffer limit passed to the
- :class:
StreamReader
. + This function is a :ref:coroutine <coroutine>
.
Use the :meth:BaseEventLoop.connect_read_pipe
and
:meth:BaseEventLoop.connect_write_pipe
methods to connect pipes.
+
+Create a subprocess: low-level API using subprocess.Popen
+---------------------------------------------------------
+
+Run subprocesses asynchronously using the :mod:subprocess
module.
+
+.. method:: BaseEventLoop.subprocess_exec(protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
+
- Create a subprocess from one or more string arguments, where the first string
- specifies the program to execute, and the remaining strings specify the
- program's arguments. (Thus, together the string arguments form the
sys.argv
value of the program, assuming it is a Python script.) This is- similar to the standard library :class:
subprocess.Popen
class called with - shell=False and the list of strings passed as the first argument;
- however, where :class:
~subprocess.Popen
takes a single argument which is - list of strings, :func:
subprocess_exec
takes multiple string arguments. + - Other parameters: +
to the subprocess's standard input stream using[](#l2.68)
:meth:`~BaseEventLoop.connect_write_pipe`, or the constant[](#l2.69)
:const:`subprocess.PIPE` (the default). By default a new pipe will be[](#l2.70)
created and connected.[](#l2.71)
to the subprocess's standard output stream using[](#l2.74)
:meth:`~BaseEventLoop.connect_read_pipe`, or the constant[](#l2.75)
:const:`subprocess.PIPE` (the default). By default a new pipe will be[](#l2.76)
created and connected.[](#l2.77)
to the subprocess's standard error stream using[](#l2.80)
:meth:`~BaseEventLoop.connect_read_pipe`, or one of the constants[](#l2.81)
:const:`subprocess.PIPE` (the default) or :const:`subprocess.STDOUT`.[](#l2.82)
By default a new pipe will be created and connected. When[](#l2.83)
:const:`subprocess.STDOUT` is specified, the subprocess's standard error[](#l2.84)
stream will be connected to the same pipe as the standard output stream.[](#l2.85)
without interpretation, except for *bufsize*, *universal_newlines* and[](#l2.88)
*shell*, which should not be specified at all.[](#l2.89)
- Returns a pair of
(transport, protocol)
, where transport is an - instance of :class:
BaseSubprocessTransport
. + - This method is a :ref:
coroutine <coroutine>
. + - See the constructor of the :class:
subprocess.Popen
class for parameters. +
+.. method:: BaseEventLoop.subprocess_shell(protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) +
- Create a subprocess from cmd, which is a string using the platform's
- "shell" syntax. This is similar to the standard library
- :class:
subprocess.Popen
class called withshell=True
. + - See :meth:
~BaseEventLoop.subprocess_exec
for more details about - the remaining arguments. +
- Returns a pair of
(transport, protocol)
, where transport is an - instance of :class:
BaseSubprocessTransport
. + - This method is a :ref:
coroutine <coroutine>
. + - See the constructor of the :class:
subprocess.Popen
class for parameters. +