Skip to content

Commit e45662c

Browse files
miss-islington1st1
andcommitted
bpo-33649: Fix gather() docs; fix title; few other nits. (GH-9475) (GH-9481)
(cherry picked from commit db1a80e) Co-authored-by: Yury Selivanov <yury@magic.io>
1 parent 914086a commit e45662c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Doc/library/asyncio-task.rst

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ other coroutines::
129129

130130
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()
134135

135136
# 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*.
309310

311+
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()``.
314318

315-
If ``gather`` is *cancelled*, all submitted awaitables
319+
If ``gather()`` is *cancelled*, all submitted awaitables
316320
(that have not completed yet) are also *cancelled*.
317321

318322
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*.
363367

364368

365-
Shielding Tasks From Cancellation
366-
=================================
369+
Shielding From Cancellation
370+
===========================
367371

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

370374
Protect an :ref:`awaitable object <asyncio-awaitables>`
371375
from being :meth:`cancelled <Task.cancel>`.
372376

373-
*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.
375378

376379
The statement::
377380

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

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

606-
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.
608611

609612
Tasks are used to run coroutines in event loops.
@@ -800,7 +803,7 @@ Task Object
800803
is used to get the current loop.
801804

802805
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.
804807

805808
.. classmethod:: current_task(loop=None)
806809

@@ -810,7 +813,8 @@ Task Object
810813
is used to get the current loop.
811814

812815
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.
814818

815819

816820
.. _asyncio_generator_based_coro:

0 commit comments

Comments
 (0)