Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f68afd85
Commit
f68afd85
authored
Aug 08, 2016
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #27700: Document AbstractEventLoop, not BaseEventLoop.
parent
08d85ee7
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
138 additions
and
129 deletions
+138
-129
Doc/library/asyncio-dev.rst
Doc/library/asyncio-dev.rst
+11
-11
Doc/library/asyncio-eventloop.rst
Doc/library/asyncio-eventloop.rst
+71
-62
Doc/library/asyncio-eventloops.rst
Doc/library/asyncio-eventloops.rst
+14
-14
Doc/library/asyncio-protocol.rst
Doc/library/asyncio-protocol.rst
+9
-9
Doc/library/asyncio-stream.rst
Doc/library/asyncio-stream.rst
+9
-9
Doc/library/asyncio-subprocess.rst
Doc/library/asyncio-subprocess.rst
+13
-13
Doc/library/asyncio-task.rst
Doc/library/asyncio-task.rst
+11
-11
No files found.
Doc/library/asyncio-dev.rst
View file @
f68afd85
...
@@ -21,7 +21,7 @@ enable *debug mode*.
...
@@ -21,7 +21,7 @@ enable *debug mode*.
To enable all debug checks for an application:
To enable all debug checks for an application:
* Enable the asyncio debug mode globally by setting the environment variable
* Enable the asyncio debug mode globally by setting the environment variable
:envvar:`PYTHONASYNCIODEBUG` to ``1``, or by calling :meth:`
Base
EventLoop.set_debug`.
:envvar:`PYTHONASYNCIODEBUG` to ``1``, or by calling :meth:`
Abstract
EventLoop.set_debug`.
* Set the log level of the :ref:`asyncio logger <asyncio-logger>` to
* Set the log level of the :ref:`asyncio logger <asyncio-logger>` to
:py:data:`logging.DEBUG`. For example, call
:py:data:`logging.DEBUG`. For example, call
``logging.basicConfig(level=logging.DEBUG)`` at startup.
``logging.basicConfig(level=logging.DEBUG)`` at startup.
...
@@ -33,18 +33,18 @@ Examples debug checks:
...
@@ -33,18 +33,18 @@ Examples debug checks:
* Log :ref:`coroutines defined but never "yielded from"
* Log :ref:`coroutines defined but never "yielded from"
<asyncio-coroutine-not-scheduled>`
<asyncio-coroutine-not-scheduled>`
* :meth:`~
BaseEventLoop.call_soon` and :meth:`~Base
EventLoop.call_at` methods
* :meth:`~
AbstractEventLoop.call_soon` and :meth:`~Abstract
EventLoop.call_at` methods
raise an exception if they are called from the wrong thread.
raise an exception if they are called from the wrong thread.
* Log the execution time of the selector
* Log the execution time of the selector
* Log callbacks taking more than 100 ms to be executed. The
* Log callbacks taking more than 100 ms to be executed. The
:attr:`
Base
EventLoop.slow_callback_duration` attribute is the minimum
:attr:`
Abstract
EventLoop.slow_callback_duration` attribute is the minimum
duration in seconds of "slow" callbacks.
duration in seconds of "slow" callbacks.
* :exc:`ResourceWarning` warnings are emitted when transports and event loops
* :exc:`ResourceWarning` warnings are emitted when transports and event loops
are :ref:`not closed explicitly <asyncio-close-transports>`.
are :ref:`not closed explicitly <asyncio-close-transports>`.
.. seealso::
.. seealso::
The :meth:`
Base
EventLoop.set_debug` method and the :ref:`asyncio logger
The :meth:`
Abstract
EventLoop.set_debug` method and the :ref:`asyncio logger
<asyncio-logger>`.
<asyncio-logger>`.
...
@@ -68,7 +68,7 @@ For example, write::
...
@@ -68,7 +68,7 @@ For example, write::
Don't schedule directly a call to the :meth:`~Future.set_result` or the
Don't schedule directly a call to the :meth:`~Future.set_result` or the
:meth:`~Future.set_exception` method of a future with
:meth:`~Future.set_exception` method of a future with
:meth:`
Base
EventLoop.call_soon`: the future can be cancelled before its method
:meth:`
Abstract
EventLoop.call_soon`: the future can be cancelled before its method
is called.
is called.
If you wait for a future, you should check early if the future was cancelled to
If you wait for a future, you should check early if the future was cancelled to
...
@@ -96,7 +96,7 @@ the same thread. But when the task uses ``yield from``, the task is suspended
...
@@ -96,7 +96,7 @@ the same thread. But when the task uses ``yield from``, the task is suspended
and the event loop executes the next task.
and the event loop executes the next task.
To schedule a callback from a different thread, the
To schedule a callback from a different thread, the
:meth:`
Base
EventLoop.call_soon_threadsafe` method should be used. Example::
:meth:`
Abstract
EventLoop.call_soon_threadsafe` method should be used. Example::
loop.call_soon_threadsafe(callback, *args)
loop.call_soon_threadsafe(callback, *args)
...
@@ -116,7 +116,7 @@ To schedule a coroutine object from a different thread, the
...
@@ -116,7 +116,7 @@ To schedule a coroutine object from a different thread, the
future = asyncio.run_coroutine_threadsafe(coro_func(), loop)
future = asyncio.run_coroutine_threadsafe(coro_func(), loop)
result = future.result(timeout) # Wait for the result with a timeout
result = future.result(timeout) # Wait for the result with a timeout
The :meth:`
Base
EventLoop.run_in_executor` method can be used with a thread pool
The :meth:`
Abstract
EventLoop.run_in_executor` method can be used with a thread pool
executor to execute a callback in different thread to not block the thread of
executor to execute a callback in different thread to not block the thread of
the event loop.
the event loop.
...
@@ -145,7 +145,7 @@ APIs like :ref:`protocols <asyncio-protocol>`.
...
@@ -145,7 +145,7 @@ APIs like :ref:`protocols <asyncio-protocol>`.
An executor can be used to run a task in a different thread or even in a
An executor can be used to run a task in a different thread or even in a
different process, to not block the thread of the event loop. See the
different process, to not block the thread of the event loop. See the
:meth:`
Base
EventLoop.run_in_executor` method.
:meth:`
Abstract
EventLoop.run_in_executor` method.
.. seealso::
.. seealso::
...
@@ -168,7 +168,7 @@ Detect coroutine objects never scheduled
...
@@ -168,7 +168,7 @@ Detect coroutine objects never scheduled
----------------------------------------
----------------------------------------
When a coroutine function is called and its result is not passed to
When a coroutine function is called and its result is not passed to
:func:`ensure_future` or to the :meth:`
Base
EventLoop.create_task` method,
:func:`ensure_future` or to the :meth:`
Abstract
EventLoop.create_task` method,
the execution of the coroutine object will never be scheduled which is
the execution of the coroutine object will never be scheduled which is
probably a bug. :ref:`Enable the debug mode of asyncio <asyncio-debug-mode>`
probably a bug. :ref:`Enable the debug mode of asyncio <asyncio-debug-mode>`
to :ref:`log a warning <asyncio-logger>` to detect it.
to :ref:`log a warning <asyncio-logger>` to detect it.
...
@@ -191,7 +191,7 @@ Output in debug mode::
...
@@ -191,7 +191,7 @@ Output in debug mode::
test()
test()
The fix is to call the :func:`ensure_future` function or the
The fix is to call the :func:`ensure_future` function or the
:meth:`
Base
EventLoop.create_task` method with the coroutine object.
:meth:`
Abstract
EventLoop.create_task` method with the coroutine object.
.. seealso::
.. seealso::
...
@@ -267,7 +267,7 @@ coroutine in another coroutine and use classic try/except::
...
@@ -267,7 +267,7 @@ coroutine in another coroutine and use classic try/except::
loop.run_forever()
loop.run_forever()
loop.close()
loop.close()
Another option is to use the :meth:`
Base
EventLoop.run_until_complete`
Another option is to use the :meth:`
Abstract
EventLoop.run_until_complete`
function::
function::
task = asyncio.ensure_future(bug())
task = asyncio.ensure_future(bug())
...
...
Doc/library/asyncio-eventloop.rst
View file @
f68afd85
This diff is collapsed.
Click to expand it.
Doc/library/asyncio-eventloops.rst
View file @
f68afd85
...
@@ -35,7 +35,7 @@ asyncio currently provides two implementations of event loops:
...
@@ -35,7 +35,7 @@ asyncio currently provides two implementations of event loops:
.. class:: SelectorEventLoop
.. class:: SelectorEventLoop
Event loop based on the :mod:`selectors` module. Subclass of
Event loop based on the :mod:`selectors` module. Subclass of
:class:`
Base
EventLoop`.
:class:`
Abstract
EventLoop`.
Use the most efficient selector available on the platform.
Use the most efficient selector available on the platform.
...
@@ -46,7 +46,7 @@ asyncio currently provides two implementations of event loops:
...
@@ -46,7 +46,7 @@ asyncio currently provides two implementations of event loops:
.. class:: ProactorEventLoop
.. class:: ProactorEventLoop
Proactor event loop for Windows using "I/O Completion Ports" aka IOCP.
Proactor event loop for Windows using "I/O Completion Ports" aka IOCP.
Subclass of :class:`
Base
EventLoop`.
Subclass of :class:`
Abstract
EventLoop`.
Availability: Windows.
Availability: Windows.
...
@@ -76,11 +76,11 @@ Windows
...
@@ -76,11 +76,11 @@ Windows
Common limits of Windows event loops:
Common limits of Windows event loops:
- :meth:`~
Base
EventLoop.create_unix_connection` and
- :meth:`~
Abstract
EventLoop.create_unix_connection` and
:meth:`~
Base
EventLoop.create_unix_server` are not supported: the socket
:meth:`~
Abstract
EventLoop.create_unix_server` are not supported: the socket
family :data:`socket.AF_UNIX` is specific to UNIX
family :data:`socket.AF_UNIX` is specific to UNIX
- :meth:`~
Base
EventLoop.add_signal_handler` and
- :meth:`~
Abstract
EventLoop.add_signal_handler` and
:meth:`~
Base
EventLoop.remove_signal_handler` are not supported
:meth:`~
Abstract
EventLoop.remove_signal_handler` are not supported
- :meth:`EventLoopPolicy.set_child_watcher` is not supported.
- :meth:`EventLoopPolicy.set_child_watcher` is not supported.
:class:`ProactorEventLoop` supports subprocesses. It has only one
:class:`ProactorEventLoop` supports subprocesses. It has only one
implementation to watch child processes, there is no need to configure it.
implementation to watch child processes, there is no need to configure it.
...
@@ -89,19 +89,19 @@ Common limits of Windows event loops:
...
@@ -89,19 +89,19 @@ Common limits of Windows event loops:
- :class:`~selectors.SelectSelector` is used which only supports sockets
- :class:`~selectors.SelectSelector` is used which only supports sockets
and is limited to 512 sockets.
and is limited to 512 sockets.
- :meth:`~
BaseEventLoop.add_reader` and :meth:`~Base
EventLoop.add_writer` only
- :meth:`~
AbstractEventLoop.add_reader` and :meth:`~Abstract
EventLoop.add_writer` only
accept file descriptors of sockets
accept file descriptors of sockets
- Pipes are not supported
- Pipes are not supported
(ex: :meth:`~
Base
EventLoop.connect_read_pipe`,
(ex: :meth:`~
Abstract
EventLoop.connect_read_pipe`,
:meth:`~
Base
EventLoop.connect_write_pipe`)
:meth:`~
Abstract
EventLoop.connect_write_pipe`)
- :ref:`Subprocesses <asyncio-subprocess>` are not supported
- :ref:`Subprocesses <asyncio-subprocess>` are not supported
(ex: :meth:`~
Base
EventLoop.subprocess_exec`,
(ex: :meth:`~
Abstract
EventLoop.subprocess_exec`,
:meth:`~
Base
EventLoop.subprocess_shell`)
:meth:`~
Abstract
EventLoop.subprocess_shell`)
:class:`ProactorEventLoop` specific limits:
:class:`ProactorEventLoop` specific limits:
- :meth:`~
Base
EventLoop.create_datagram_endpoint` (UDP) is not supported
- :meth:`~
Abstract
EventLoop.create_datagram_endpoint` (UDP) is not supported
- :meth:`~
BaseEventLoop.add_reader` and :meth:`~Base
EventLoop.add_writer` are
- :meth:`~
AbstractEventLoop.add_reader` and :meth:`~Abstract
EventLoop.add_writer` are
not supported
not supported
The resolution of the monotonic clock on Windows is usually around 15.6 msec.
The resolution of the monotonic clock on Windows is usually around 15.6 msec.
...
@@ -167,7 +167,7 @@ An event loop policy must implement the following interface:
...
@@ -167,7 +167,7 @@ An event loop policy must implement the following interface:
Get the event loop for the current context.
Get the event loop for the current context.
Returns an event loop object implementing the :class:`
Base
EventLoop`
Returns an event loop object implementing the :class:`
Abstract
EventLoop`
interface.
interface.
Raises an exception in case no event loop has been set for the current
Raises an exception in case no event loop has been set for the current
...
...
Doc/library/asyncio-protocol.rst
View file @
f68afd85
...
@@ -11,7 +11,7 @@ Transports
...
@@ -11,7 +11,7 @@ Transports
Transports are classes provided by :mod:`asyncio` in order to abstract
Transports are classes provided by :mod:`asyncio` in order to abstract
various kinds of communication channels. You generally won't instantiate
various kinds of communication channels. You generally won't instantiate
a transport yourself; instead, you will call a :class:`
Base
EventLoop` method
a transport yourself; instead, you will call a :class:`
Abstract
EventLoop` method
which will create the transport and try to initiate the underlying
which will create the transport and try to initiate the underlying
communication channel, calling you back when it succeeds.
communication channel, calling you back when it succeeds.
...
@@ -475,7 +475,7 @@ Protocol examples
...
@@ -475,7 +475,7 @@ Protocol examples
TCP echo client protocol
TCP echo client protocol
------------------------
------------------------
TCP echo client using the :meth:`
Base
EventLoop.create_connection` method, send
TCP echo client using the :meth:`
Abstract
EventLoop.create_connection` method, send
data and wait until the connection is closed::
data and wait until the connection is closed::
import asyncio
import asyncio
...
@@ -506,10 +506,10 @@ data and wait until the connection is closed::
...
@@ -506,10 +506,10 @@ data and wait until the connection is closed::
loop.close()
loop.close()
The event loop is running twice. The
The event loop is running twice. The
:meth:`~
Base
EventLoop.run_until_complete` method is preferred in this short
:meth:`~
Abstract
EventLoop.run_until_complete` method is preferred in this short
example to raise an exception if the server is not listening, instead of
example to raise an exception if the server is not listening, instead of
having to write a short coroutine to handle the exception and stop the
having to write a short coroutine to handle the exception and stop the
running loop. At :meth:`~
Base
EventLoop.run_until_complete` exit, the loop is
running loop. At :meth:`~
Abstract
EventLoop.run_until_complete` exit, the loop is
no longer running, so there is no need to stop the loop in case of an error.
no longer running, so there is no need to stop the loop in case of an error.
.. seealso::
.. seealso::
...
@@ -523,7 +523,7 @@ no longer running, so there is no need to stop the loop in case of an error.
...
@@ -523,7 +523,7 @@ no longer running, so there is no need to stop the loop in case of an error.
TCP echo server protocol
TCP echo server protocol
------------------------
------------------------
TCP echo server using the :meth:`
Base
EventLoop.create_server` method, send back
TCP echo server using the :meth:`
Abstract
EventLoop.create_server` method, send back
received data and close the connection::
received data and close the connection::
import asyncio
import asyncio
...
@@ -577,7 +577,7 @@ methods are not coroutines.
...
@@ -577,7 +577,7 @@ methods are not coroutines.
UDP echo client protocol
UDP echo client protocol
------------------------
------------------------
UDP echo client using the :meth:`
Base
EventLoop.create_datagram_endpoint`
UDP echo client using the :meth:`
Abstract
EventLoop.create_datagram_endpoint`
method, send data and close the transport when we received the answer::
method, send data and close the transport when we received the answer::
import asyncio
import asyncio
...
@@ -623,7 +623,7 @@ method, send data and close the transport when we received the answer::
...
@@ -623,7 +623,7 @@ method, send data and close the transport when we received the answer::
UDP echo server protocol
UDP echo server protocol
------------------------
------------------------
UDP echo server using the :meth:`
Base
EventLoop.create_datagram_endpoint`
UDP echo server using the :meth:`
Abstract
EventLoop.create_datagram_endpoint`
method, send back received data::
method, send back received data::
import asyncio
import asyncio
...
@@ -660,7 +660,7 @@ Register an open socket to wait for data using a protocol
...
@@ -660,7 +660,7 @@ Register an open socket to wait for data using a protocol
---------------------------------------------------------
---------------------------------------------------------
Wait until a socket receives data using the
Wait until a socket receives data using the
:meth:`
Base
EventLoop.create_connection` method with a protocol, and then close
:meth:`
Abstract
EventLoop.create_connection` method with a protocol, and then close
the event loop ::
the event loop ::
import asyncio
import asyncio
...
@@ -708,7 +708,7 @@ the event loop ::
...
@@ -708,7 +708,7 @@ the event loop ::
The :ref:`watch a file descriptor for read events
The :ref:`watch a file descriptor for read events
<asyncio-watch-read-event>` example uses the low-level
<asyncio-watch-read-event>` example uses the low-level
:meth:`
Base
EventLoop.add_reader` method to register the file descriptor of a
:meth:`
Abstract
EventLoop.add_reader` method to register the file descriptor of a
socket.
socket.
The :ref:`register an open socket to wait for data using streams
The :ref:`register an open socket to wait for data using streams
...
...
Doc/library/asyncio-stream.rst
View file @
f68afd85
...
@@ -18,14 +18,14 @@ Stream functions
...
@@ -18,14 +18,14 @@ Stream functions
.. coroutinefunction:: open_connection(host=None, port=None, \*, loop=None, limit=None, \*\*kwds)
.. coroutinefunction:: open_connection(host=None, port=None, \*, loop=None, limit=None, \*\*kwds)
A wrapper for :meth:`~
Base
EventLoop.create_connection()` returning a (reader,
A wrapper for :meth:`~
Abstract
EventLoop.create_connection()` returning a (reader,
writer) pair.
writer) pair.
The reader returned is a :class:`StreamReader` instance; the writer is
The reader returned is a :class:`StreamReader` instance; the writer is
a :class:`StreamWriter` instance.
a :class:`StreamWriter` instance.
The arguments are all the usual arguments to
The arguments are all the usual arguments to
:meth:`
Base
EventLoop.create_connection` except *protocol_factory*; most
:meth:`
Abstract
EventLoop.create_connection` except *protocol_factory*; most
common are positional host and port, with various optional keyword arguments
common are positional host and port, with various optional keyword arguments
following.
following.
...
@@ -38,7 +38,7 @@ Stream functions
...
@@ -38,7 +38,7 @@ Stream functions
.. coroutinefunction:: start_server(client_connected_cb, host=None, port=None, \*, loop=None, limit=None, \*\*kwds)
.. coroutinefunction:: start_server(client_connected_cb, host=None, port=None, \*, loop=None, limit=None, \*\*kwds)
Start a socket server, with a callback for each client connected. The return
Start a socket server, with a callback for each client connected. The return
value is the same as :meth:`~
Base
EventLoop.create_server()`.
value is the same as :meth:`~
Abstract
EventLoop.create_server()`.
The *client_connected_cb* parameter is called with two parameters:
The *client_connected_cb* parameter is called with two parameters:
*client_reader*, *client_writer*. *client_reader* is a
*client_reader*, *client_writer*. *client_reader* is a
...
@@ -49,7 +49,7 @@ Stream functions
...
@@ -49,7 +49,7 @@ Stream functions
converted into a :class:`Task`.
converted into a :class:`Task`.
The rest of the arguments are all the usual arguments to
The rest of the arguments are all the usual arguments to
:meth:`~
Base
EventLoop.create_server()` except *protocol_factory*; most
:meth:`~
Abstract
EventLoop.create_server()` except *protocol_factory*; most
common are positional *host* and *port*, with various optional keyword
common are positional *host* and *port*, with various optional keyword
arguments following.
arguments following.
...
@@ -61,7 +61,7 @@ Stream functions
...
@@ -61,7 +61,7 @@ Stream functions
.. coroutinefunction:: open_unix_connection(path=None, \*, loop=None, limit=None, **kwds)
.. coroutinefunction:: open_unix_connection(path=None, \*, loop=None, limit=None, **kwds)
A wrapper for :meth:`~
Base
EventLoop.create_unix_connection()` returning
A wrapper for :meth:`~
Abstract
EventLoop.create_unix_connection()` returning
a (reader, writer) pair.
a (reader, writer) pair.
See :func:`open_connection` for information about return value and other
See :func:`open_connection` for information about return value and other
...
@@ -321,7 +321,7 @@ TCP echo client using the :func:`asyncio.open_connection` function::
...
@@ -321,7 +321,7 @@ TCP echo client using the :func:`asyncio.open_connection` function::
.. seealso::
.. seealso::
The :ref:`TCP echo client protocol <asyncio-tcp-echo-client-protocol>`
The :ref:`TCP echo client protocol <asyncio-tcp-echo-client-protocol>`
example uses the :meth:`
Base
EventLoop.create_connection` method.
example uses the :meth:`
Abstract
EventLoop.create_connection` method.
.. _asyncio-tcp-echo-server-streams:
.. _asyncio-tcp-echo-server-streams:
...
@@ -366,7 +366,7 @@ TCP echo server using the :func:`asyncio.start_server` function::
...
@@ -366,7 +366,7 @@ TCP echo server using the :func:`asyncio.start_server` function::
.. seealso::
.. seealso::
The :ref:`TCP echo server protocol <asyncio-tcp-echo-server-protocol>`
The :ref:`TCP echo server protocol <asyncio-tcp-echo-server-protocol>`
example uses the :meth:`
Base
EventLoop.create_server` method.
example uses the :meth:`
Abstract
EventLoop.create_server` method.
Get HTTP headers
Get HTTP headers
...
@@ -458,10 +458,10 @@ Coroutine waiting until a socket receives data using the
...
@@ -458,10 +458,10 @@ Coroutine waiting until a socket receives data using the
The :ref:`register an open socket to wait for data using a protocol
The :ref:`register an open socket to wait for data using a protocol
<asyncio-register-socket>` example uses a low-level protocol created by the
<asyncio-register-socket>` example uses a low-level protocol created by the
:meth:`
Base
EventLoop.create_connection` method.
:meth:`
Abstract
EventLoop.create_connection` method.
The :ref:`watch a file descriptor for read events
The :ref:`watch a file descriptor for read events
<asyncio-watch-read-event>` example uses the low-level
<asyncio-watch-read-event>` example uses the low-level
:meth:`
Base
EventLoop.add_reader` method to register the file descriptor of a
:meth:`
Abstract
EventLoop.add_reader` method to register the file descriptor of a
socket.
socket.
Doc/library/asyncio-subprocess.rst
View file @
f68afd85
...
@@ -32,7 +32,7 @@ Create a subprocess: high-level API using Process
...
@@ -32,7 +32,7 @@ Create a subprocess: high-level API using Process
Create a subprocess.
Create a subprocess.
The *limit* parameter sets the buffer limit passed to the
The *limit* parameter sets the buffer limit passed to the
:class:`StreamReader`. See :meth:`
Base
EventLoop.subprocess_exec` for other
:class:`StreamReader`. See :meth:`
Abstract
EventLoop.subprocess_exec` for other
parameters.
parameters.
Return a :class:`~asyncio.subprocess.Process` instance.
Return a :class:`~asyncio.subprocess.Process` instance.
...
@@ -44,7 +44,7 @@ Create a subprocess: high-level API using Process
...
@@ -44,7 +44,7 @@ Create a subprocess: high-level API using Process
Run the shell command *cmd*.
Run the shell command *cmd*.
The *limit* parameter sets the buffer limit passed to the
The *limit* parameter sets the buffer limit passed to the
:class:`StreamReader`. See :meth:`
Base
EventLoop.subprocess_shell` for other
:class:`StreamReader`. See :meth:`
Abstract
EventLoop.subprocess_shell` for other
parameters.
parameters.
Return a :class:`~asyncio.subprocess.Process` instance.
Return a :class:`~asyncio.subprocess.Process` instance.
...
@@ -58,8 +58,8 @@ Create a subprocess: high-level API using Process
...
@@ -58,8 +58,8 @@ Create a subprocess: high-level API using Process
This function is a :ref:`coroutine <coroutine>`.
This function is a :ref:`coroutine <coroutine>`.
Use the :meth:`
Base
EventLoop.connect_read_pipe` and
Use the :meth:`
Abstract
EventLoop.connect_read_pipe` and
:meth:`
Base
EventLoop.connect_write_pipe` methods to connect pipes.
:meth:`
Abstract
EventLoop.connect_write_pipe` methods to connect pipes.
Create a subprocess: low-level API using subprocess.Popen
Create a subprocess: low-level API using subprocess.Popen
...
@@ -67,7 +67,7 @@ Create a subprocess: low-level API using subprocess.Popen
...
@@ -67,7 +67,7 @@ Create a subprocess: low-level API using subprocess.Popen
Run subprocesses asynchronously using the :mod:`subprocess` module.
Run subprocesses asynchronously using the :mod:`subprocess` module.
.. coroutinemethod::
Base
EventLoop.subprocess_exec(protocol_factory, \*args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, \*\*kwargs)
.. coroutinemethod::
Abstract
EventLoop.subprocess_exec(protocol_factory, \*args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, \*\*kwargs)
Create a subprocess from one or more string arguments (character strings or
Create a subprocess from one or more string arguments (character strings or
bytes strings encoded to the :ref:`filesystem encoding
bytes strings encoded to the :ref:`filesystem encoding
...
@@ -87,19 +87,19 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
...
@@ -87,19 +87,19 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
* *stdin*: Either a file-like object representing the pipe to be connected
* *stdin*: Either a file-like object representing the pipe to be connected
to the subprocess's standard input stream using
to the subprocess's standard input stream using
:meth:`~
Base
EventLoop.connect_write_pipe`, or the constant
:meth:`~
Abstract
EventLoop.connect_write_pipe`, or the constant
:const:`subprocess.PIPE` (the default). By default a new pipe will be
:const:`subprocess.PIPE` (the default). By default a new pipe will be
created and connected.
created and connected.
* *stdout*: Either a file-like object representing the pipe to be connected
* *stdout*: Either a file-like object representing the pipe to be connected
to the subprocess's standard output stream using
to the subprocess's standard output stream using
:meth:`~
Base
EventLoop.connect_read_pipe`, or the constant
:meth:`~
Abstract
EventLoop.connect_read_pipe`, or the constant
:const:`subprocess.PIPE` (the default). By default a new pipe will be
:const:`subprocess.PIPE` (the default). By default a new pipe will be
created and connected.
created and connected.
* *stderr*: Either a file-like object representing the pipe to be connected
* *stderr*: Either a file-like object representing the pipe to be connected
to the subprocess's standard error stream using
to the subprocess's standard error stream using
:meth:`~
Base
EventLoop.connect_read_pipe`, or one of the constants
:meth:`~
Abstract
EventLoop.connect_read_pipe`, or one of the constants
:const:`subprocess.PIPE` (the default) or :const:`subprocess.STDOUT`.
:const:`subprocess.PIPE` (the default) or :const:`subprocess.STDOUT`.
By default a new pipe will be created and connected. When
By default a new pipe will be created and connected. When
:const:`subprocess.STDOUT` is specified, the subprocess's standard error
:const:`subprocess.STDOUT` is specified, the subprocess's standard error
...
@@ -116,7 +116,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
...
@@ -116,7 +116,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
See the constructor of the :class:`subprocess.Popen` class for parameters.
See the constructor of the :class:`subprocess.Popen` class for parameters.
.. coroutinemethod::
Base
EventLoop.subprocess_shell(protocol_factory, cmd, \*, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, \*\*kwargs)
.. coroutinemethod::
Abstract
EventLoop.subprocess_shell(protocol_factory, cmd, \*, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, \*\*kwargs)
Create a subprocess from *cmd*, which is a character string or a bytes
Create a subprocess from *cmd*, which is a character string or a bytes
string encoded to the :ref:`filesystem encoding <filesystem-encoding>`,
string encoded to the :ref:`filesystem encoding <filesystem-encoding>`,
...
@@ -126,7 +126,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
...
@@ -126,7 +126,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
The *protocol_factory* must instanciate a subclass of the
The *protocol_factory* must instanciate a subclass of the
:class:`asyncio.SubprocessProtocol` class.
:class:`asyncio.SubprocessProtocol` class.
See :meth:`~
Base
EventLoop.subprocess_exec` for more details about
See :meth:`~
Abstract
EventLoop.subprocess_exec` for more details about
the remaining arguments.
the remaining arguments.
Returns a pair of ``(transport, protocol)``, where *transport* is an
Returns a pair of ``(transport, protocol)``, where *transport* is an
...
@@ -143,8 +143,8 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
...
@@ -143,8 +143,8 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
.. seealso::
.. seealso::
The :meth:`
Base
EventLoop.connect_read_pipe` and
The :meth:`
Abstract
EventLoop.connect_read_pipe` and
:meth:`
Base
EventLoop.connect_write_pipe` methods.
:meth:`
Abstract
EventLoop.connect_write_pipe` methods.
Constants
Constants
...
@@ -329,7 +329,7 @@ Subprocess using transport and protocol
...
@@ -329,7 +329,7 @@ Subprocess using transport and protocol
Example of a subprocess protocol using to get the output of a subprocess and to
Example of a subprocess protocol using to get the output of a subprocess and to
wait for the subprocess exit. The subprocess is created by the
wait for the subprocess exit. The subprocess is created by the
:meth:`
Base
EventLoop.subprocess_exec` method::
:meth:`
Abstract
EventLoop.subprocess_exec` method::
import asyncio
import asyncio
import sys
import sys
...
...
Doc/library/asyncio-task.rst
View file @
f68afd85
...
@@ -59,7 +59,7 @@ the coroutine object returned by the call doesn't do anything until you
...
@@ -59,7 +59,7 @@ the coroutine object returned by the call doesn't do anything until you
schedule its execution. There are two basic ways to start it running:
schedule its execution. There are two basic ways to start it running:
call ``await coroutine`` or ``yield from coroutine`` from another coroutine
call ``await coroutine`` or ``yield from coroutine`` from another coroutine
(assuming the other coroutine is already running!), or schedule its execution
(assuming the other coroutine is already running!), or schedule its execution
using the :func:`ensure_future` function or the :meth:`
Base
EventLoop.create_task`
using the :func:`ensure_future` function or the :meth:`
Abstract
EventLoop.create_task`
method.
method.
...
@@ -108,7 +108,7 @@ Example of coroutine displaying ``"Hello World"``::
...
@@ -108,7 +108,7 @@ Example of coroutine displaying ``"Hello World"``::
.. seealso::
.. seealso::
The :ref:`Hello World with call_soon() <asyncio-hello-world-callback>`
The :ref:`Hello World with call_soon() <asyncio-hello-world-callback>`
example uses the :meth:`
Base
EventLoop.call_soon` method to schedule a
example uses the :meth:`
Abstract
EventLoop.call_soon` method to schedule a
callback.
callback.
...
@@ -151,7 +151,7 @@ The same coroutine implemented using a generator::
...
@@ -151,7 +151,7 @@ The same coroutine implemented using a generator::
The :ref:`display the current date with call_later()
The :ref:`display the current date with call_later()
<asyncio-date-callback>` example uses a callback with the
<asyncio-date-callback>` example uses a callback with the
:meth:`
Base
EventLoop.call_later` method.
:meth:`
Abstract
EventLoop.call_later` method.
Example: Chain coroutines
Example: Chain coroutines
...
@@ -182,12 +182,12 @@ Sequence diagram of the example:
...
@@ -182,12 +182,12 @@ Sequence diagram of the example:
.. image:: tulip_coro.png
.. image:: tulip_coro.png
:align: center
:align: center
The "Task" is created by the :meth:`
Base
EventLoop.run_until_complete` method
The "Task" is created by the :meth:`
Abstract
EventLoop.run_until_complete` method
when it gets a coroutine object instead of a task.
when it gets a coroutine object instead of a task.
The diagram shows the control flow, it does not describe exactly how things
The diagram shows the control flow, it does not describe exactly how things
work internally. For example, the sleep coroutine creates an internal future
work internally. For example, the sleep coroutine creates an internal future
which uses :meth:`
Base
EventLoop.call_later` to wake up the task in 1 second.
which uses :meth:`
Abstract
EventLoop.call_later` to wake up the task in 1 second.
InvalidStateError
InvalidStateError
...
@@ -223,7 +223,7 @@ Future
...
@@ -223,7 +223,7 @@ Future
raise an exception when the future isn't done yet.
raise an exception when the future isn't done yet.
- Callbacks registered with :meth:`add_done_callback` are always called
- Callbacks registered with :meth:`add_done_callback` are always called
via the event loop's :meth:`~
Base
EventLoop.call_soon_threadsafe`.
via the event loop's :meth:`~
Abstract
EventLoop.call_soon_threadsafe`.
- This class is not compatible with the :func:`~concurrent.futures.wait` and
- This class is not compatible with the :func:`~concurrent.futures.wait` and
:func:`~concurrent.futures.as_completed` functions in the
:func:`~concurrent.futures.as_completed` functions in the
...
@@ -273,7 +273,7 @@ Future
...
@@ -273,7 +273,7 @@ Future
The callback is called with a single argument - the future object. If the
The callback is called with a single argument - the future object. If the
future is already done when this is called, the callback is scheduled
future is already done when this is called, the callback is scheduled
with :meth:`~
Base
EventLoop.call_soon`.
with :meth:`~
Abstract
EventLoop.call_soon`.
:ref:`Use functools.partial to pass parameters to the callback
:ref:`Use functools.partial to pass parameters to the callback
<asyncio-pass-keywords>`. For example,
<asyncio-pass-keywords>`. For example,
...
@@ -323,11 +323,11 @@ Example combining a :class:`Future` and a :ref:`coroutine function
...
@@ -323,11 +323,11 @@ Example combining a :class:`Future` and a :ref:`coroutine function
The coroutine function is responsible for the computation (which takes 1 second)
The coroutine function is responsible for the computation (which takes 1 second)
and it stores the result into the future. The
and it stores the result into the future. The
:meth:`~
Base
EventLoop.run_until_complete` method waits for the completion of
:meth:`~
Abstract
EventLoop.run_until_complete` method waits for the completion of
the future.
the future.
.. note::
.. note::
The :meth:`~
Base
EventLoop.run_until_complete` method uses internally the
The :meth:`~
Abstract
EventLoop.run_until_complete` method uses internally the
:meth:`~Future.add_done_callback` method to be notified when the future is
:meth:`~Future.add_done_callback` method to be notified when the future is
done.
done.
...
@@ -396,7 +396,7 @@ Task
...
@@ -396,7 +396,7 @@ Task
logged: see :ref:`Pending task destroyed <asyncio-pending-task-destroyed>`.
logged: see :ref:`Pending task destroyed <asyncio-pending-task-destroyed>`.
Don't directly create :class:`Task` instances: use the :func:`ensure_future`
Don't directly create :class:`Task` instances: use the :func:`ensure_future`
function or the :meth:`
Base
EventLoop.create_task` method.
function or the :meth:`
Abstract
EventLoop.create_task` method.
This class is :ref:`not thread safe <asyncio-multithreading>`.
This class is :ref:`not thread safe <asyncio-multithreading>`.
...
@@ -546,7 +546,7 @@ Task functions
...
@@ -546,7 +546,7 @@ Task functions
.. seealso::
.. seealso::
The :meth:`
Base
EventLoop.create_task` method.
The :meth:`
Abstract
EventLoop.create_task` method.
.. function:: async(coro_or_future, \*, loop=None)
.. function:: async(coro_or_future, \*, loop=None)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment