asyncio doc: replace "coroutine" with "coroutine object" or "coroutine function"

This commit is contained in:
Victor Stinner 2014-01-16 19:30:21 +01:00
parent db39a0da0c
commit 59759ff234
4 changed files with 41 additions and 39 deletions

View File

@ -158,7 +158,7 @@ Creating connections
*port*. *protocol_factory* must be a callable returning a
:ref:`protocol <protocol>` instance.
This method returns a :ref:`coroutine <coroutine>` which will try to
This method returns a :ref:`coroutine object <coroutine>` which will try to
establish the connection in the background. When successful, the
coroutine returns a ``(transport, protocol)`` pair.
@ -219,7 +219,7 @@ Creating listening connections
.. method:: BaseEventLoop.create_server(protocol_factory, host=None, port=None, \*, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None)
A :ref:`coroutine <coroutine>` which creates a TCP server bound to host and
A :ref:`coroutine function <coroutine>` which creates a TCP server bound to host and
port.
The return value is a :class:`AbstractServer` object which can be used to stop
@ -249,13 +249,13 @@ Creating listening connections
expire. If not specified will automatically be set to True on
UNIX.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: BaseEventLoop.create_datagram_endpoint(protocol_factory, local_addr=None, remote_addr=None, \*, family=0, proto=0, flags=0)
Create datagram connection.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
@ -280,7 +280,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
XXX
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
See the constructor of the :class:`subprocess.Popen` class for parameters.
@ -288,7 +288,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
XXX
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
See the constructor of the :class:`subprocess.Popen` class for parameters.
@ -301,7 +301,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
Return pair (transport, protocol), where transport support
:class:`ReadTransport` interface.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: BaseEventLoop.connect_write_pipe(protocol_factory, pipe)
@ -312,7 +312,7 @@ Run subprocesses asynchronously using the :mod:`subprocess` module.
Return pair (transport, protocol), where transport support
:class:`WriteTransport` interface.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
Executor

View File

@ -320,19 +320,19 @@ StreamReader
XXX
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: readline()
XXX
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: readexactly(n)
XXX
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
@ -550,7 +550,7 @@ Network functions
:class:`StreamReaderProtocol` classes, just copy the code -- there's really
nothing special here except some convenience.)
This function returns a :ref:`coroutine <coroutine>`.
This function returns a :ref:`coroutine object <coroutine>`.
.. function:: start_server(client_connected_cb, host=None, port=None, *, loop=None, limit=_DEFAULT_LIMIT, **kwds)
@ -560,8 +560,8 @@ Network functions
*client_reader*, *client_writer*. *client_reader* is a
:class:`StreamReader` object, while *client_writer* is a
:class:`StreamWriter` object. This parameter can either be a plain callback
function or a :ref:`coroutine <coroutine>`; if it is a coroutine, it will be
automatically converted into a :class:`Task`.
function or a :ref:`coroutine function <coroutine>`; if it is a coroutine
function, it will be automatically converted into a :class:`Task`.
The rest of the arguments are all the usual arguments to
:meth:`~BaseEventLoop.create_server()` except *protocol_factory*; most
@ -576,7 +576,7 @@ Network functions
The return value is the same as :meth:`~BaseEventLoop.create_server()`, i.e.
a :class:`AbstractServer` object which can be used to stop the service.
This function returns a :ref:`coroutine <coroutine>`.
This function returns a :ref:`coroutine object <coroutine>`.
Protocol example: TCP echo server and client

View File

@ -70,7 +70,7 @@ Locks
This method blocks until the lock is unlocked, then sets it to locked and
returns ``True``.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: release()
@ -118,7 +118,7 @@ Locks
Otherwise, block until another coroutine calls :meth:`set` to set the
flag to true, then return ``True``.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. class:: Condition(\*, loop=None)
@ -166,7 +166,7 @@ Locks
condition variable in another coroutine. Once awakened, it re-acquires
the lock and returns ``True``.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: wait_for(predicate)
@ -175,7 +175,7 @@ Locks
The predicate should be a callable which result will be interpreted as a
boolean value. The final predicate value is the return value.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
Semaphores
@ -205,7 +205,7 @@ Semaphores
until some other coroutine has called :meth:`release` to make it larger
than ``0``, and then return ``True``.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: locked()
@ -261,7 +261,7 @@ Queues
If you yield from :meth:`get()`, wait until a item is available.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: get_nowait()
@ -277,7 +277,7 @@ Queues
If you yield from ``put()``, wait until a free slot is available before
adding item.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: put_nowait(item)
@ -323,7 +323,7 @@ Queues
it is complete. When the count of unfinished tasks drops to zero,
:meth:`join` unblocks.
This method returns a :ref:`coroutine <coroutine>`.
This method returns a :ref:`coroutine object <coroutine>`.
.. method:: task_done()

View File

@ -19,7 +19,7 @@ The word "coroutine", like the word "generator", is used for two
different (though related) concepts:
- The function that defines a coroutine (a function definition
decorated with ``asyncio.coroutine``). If disambiguation is needed
decorated with ``@asyncio.coroutine``). If disambiguation is needed
we will call this a *coroutine function*.
- The object obtained by calling a coroutine function. This object
@ -117,7 +117,7 @@ Sequence diagram of the example:
:align: center
The "Task" is created by the :meth:`BaseEventLoop.run_until_complete` method
when it gets a coroutine 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
work internally. For example, the sleep coroutine creates an internal future
@ -219,7 +219,8 @@ Future
Example: Future with run_until_complete()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Example combining a :class:`Future` and a :ref:`coroutine <coroutine>`::
Example combining a :class:`Future` and a :ref:`coroutine function
<coroutine>`::
import asyncio
@ -234,8 +235,8 @@ Example combining a :class:`Future` and a :ref:`coroutine <coroutine>`::
loop.run_until_complete(future)
print(future.result())
The coroutine is responsible of the computation (which takes 1 second) and
it stores the result into the future. The
The coroutine function is responsible of the computation (which takes 1 second)
and it stores the result into the future. The
:meth:`~BaseEventLoop.run_until_complete` method waits for the completion of
the future.
@ -273,9 +274,9 @@ In this example, the future is responsible to display the result and to stop
the loop.
.. note::
The coroutine is only executed when the event loop starts running, so it is
possible to add a "done callback" to the future after creating the task
scheduling the coroutine.
The "slow_operation" coroutine object is only executed when the event loop
starts running, so it is possible to add a "done callback" to the future
after creating the task scheduling the coroutine object.
@ -284,7 +285,7 @@ Task
.. class:: Task(coro, \*, loop=None)
A coroutine wrapped in a :class:`Future`. Subclass of :class:`Future`.
A coroutine object wrapped in a :class:`Future`. Subclass of :class:`Future`.
.. classmethod:: all_tasks(loop=None)
@ -392,13 +393,14 @@ Task functions
.. function:: async(coro_or_future, \*, loop=None)
Wrap a :ref:`coroutine <coroutine>` in a future.
Wrap a :ref:`coroutine object <coroutine>` in a future.
If the argument is a :class:`Future`, it is returned directly.
.. function:: gather(\*coros_or_futures, loop=None, return_exceptions=False)
Return a future aggregating results from the given coroutines or futures.
Return a future aggregating results from the given coroutine objects or
futures.
All futures must share the same event loop. If all the tasks are done
successfully, the returned future's result is the list of results (in the
@ -416,8 +418,8 @@ Task functions
.. function:: sleep(delay, result=None, \*, loop=None)
Create a :ref:`coroutine <coroutine>` that completes after a given time
(in seconds).
Create a :ref:`coroutine object <coroutine>` that completes after a given
time (in seconds).
.. function:: shield(arg, \*, loop=None)
@ -448,8 +450,8 @@ Task functions
.. function:: wait(futures, \*, loop=None, timeout=None, return_when=ALL_COMPLETED)
Wait for the Futures and coroutines given by the sequence *futures* to
complete. Coroutines will be wrapped in Tasks. Returns two sets of
Wait for the Futures and coroutine objects given by the sequence *futures*
to complete. Coroutines will be wrapped in Tasks. Returns two sets of
:class:`Future`: (done, pending).
*timeout* can be used to control the maximum number of seconds to wait before
@ -477,7 +479,7 @@ Task functions
| | futures finish or are cancelled. |
+-----------------------------+----------------------------------------+
This function returns a :ref:`coroutine <coroutine>`.
This function returns a :ref:`coroutine object <coroutine>`.
Usage::