bpo-33649: Fix gather() docs; fix title; few other nits. (GH-9475) (G… · python/cpython@e45662c

@@ -129,7 +129,8 @@ other coroutines::

129129130130

async def main():

131131

# Nothing happens if we just call "nested()".

132-

# (a coroutine object is created but not awaited)

132+

# A coroutine object is created but not awaited,

133+

# so it *won't run at all*.

133134

nested()

134135135136

# Let's do it differently now and await it:

@@ -307,12 +308,15 @@ Running Tasks Concurrently

307308

aggregate list of returned values. The order of result values

308309

corresponds to the order of awaitables in *aws*.

309310311+

If *return_exceptions* is ``False`` (default), the first

312+

raised exception is immediately propagated to the task that

313+

awaits on ``gather()``. Other awaitables in the *aws* sequence

314+

**won't be cancelled** and will continue to run.

315+310316

If *return_exceptions* is ``True``, exceptions are treated the

311317

same as successful results, and aggregated in the result list.

312-

Otherwise, the first raised exception is immediately propagated

313-

to the task that awaits on ``gather()``.

314318315-

If ``gather`` is *cancelled*, all submitted awaitables

319+

If ``gather()`` is *cancelled*, all submitted awaitables

316320

(that have not completed yet) are also *cancelled*.

317321318322

If any Task or Future from the *aws* sequence is *cancelled*, it is

@@ -362,16 +366,15 @@ Running Tasks Concurrently

362366

propagated regardless of *return_exceptions*.

363367364368365-

Shielding Tasks From Cancellation

366-

=================================

369+

Shielding From Cancellation

370+

===========================

367371368372

.. awaitablefunction:: shield(aw, \*, loop=None)

369373370374

Protect an :ref:`awaitable object <asyncio-awaitables>`

371375

from being :meth:`cancelled <Task.cancel>`.

372376373-

*aw* can be a coroutine, a Task, or a Future-like object. If

374-

*aw* is a coroutine it is automatically scheduled as a Task.

377+

If *aw* is a coroutine it is automatically scheduled as a Task.

375378376379

The statement::

377380

@@ -603,7 +606,7 @@ Task Object

603606604607

.. class:: Task(coro, \*, loop=None)

605608606-

A :class:`Future`-like object that wraps a Python

609+

A :class:`Future-like <Future>` object that runs a Python

607610

:ref:`coroutine <coroutine>`. Not thread-safe.

608611609612

Tasks are used to run coroutines in event loops.

@@ -800,7 +803,7 @@ Task Object

800803

is used to get the current loop.

801804802805

This method is **deprecated** and will be removed in

803-

Python 3.9. Use the :func:`all_tasks` function instead.

806+

Python 3.9. Use the :func:`asyncio.all_tasks` function instead.

804807805808

.. classmethod:: current_task(loop=None)

806809

@@ -810,7 +813,8 @@ Task Object

810813

is used to get the current loop.

811814812815

This method is **deprecated** and will be removed in

813-

Python 3.9. Use the :func:`current_task` function instead.

816+

Python 3.9. Use the :func:`asyncio.current_task` function

817+

instead.

814818815819816820

.. _asyncio_generator_based_coro: