X Tutup
Skip to content

Commit db1a80e

Browse files
authored
bpo-33649: Fix gather() docs; fix title; few other nits. (pythonGH-9475)
1 parent 7d16172 commit db1a80e

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:
@@ -313,12 +314,15 @@ Running Tasks Concurrently
313314
aggregate list of returned values. The order of result values
314315
corresponds to the order of awaitables in *aws*.
315316

317+
If *return_exceptions* is ``False`` (default), the first
318+
raised exception is immediately propagated to the task that
319+
awaits on ``gather()``. Other awaitables in the *aws* sequence
320+
**won't be cancelled** and will continue to run.
321+
316322
If *return_exceptions* is ``True``, exceptions are treated the
317323
same as successful results, and aggregated in the result list.
318-
Otherwise, the first raised exception is immediately propagated
319-
to the task that awaits on ``gather()``.
320324

321-
If ``gather`` is *cancelled*, all submitted awaitables
325+
If ``gather()`` is *cancelled*, all submitted awaitables
322326
(that have not completed yet) are also *cancelled*.
323327

324328
If any Task or Future from the *aws* sequence is *cancelled*, it is
@@ -368,16 +372,15 @@ Running Tasks Concurrently
368372
propagated regardless of *return_exceptions*.
369373

370374

371-
Shielding Tasks From Cancellation
372-
=================================
375+
Shielding From Cancellation
376+
===========================
373377

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

376380
Protect an :ref:`awaitable object <asyncio-awaitables>`
377381
from being :meth:`cancelled <Task.cancel>`.
378382

379-
*aw* can be a coroutine, a Task, or a Future-like object. If
380-
*aw* is a coroutine it is automatically scheduled as a Task.
383+
If *aw* is a coroutine it is automatically scheduled as a Task.
381384

382385
The statement::
383386

@@ -609,7 +612,7 @@ Task Object
609612

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

612-
A :class:`Future`-like object that wraps a Python
615+
A :class:`Future-like <Future>` object that runs a Python
613616
:ref:`coroutine <coroutine>`. Not thread-safe.
614617

615618
Tasks are used to run coroutines in event loops.
@@ -831,7 +834,7 @@ Task Object
831834
is used to get the current loop.
832835

833836
This method is **deprecated** and will be removed in
834-
Python 3.9. Use the :func:`all_tasks` function instead.
837+
Python 3.9. Use the :func:`asyncio.all_tasks` function instead.
835838

836839
.. classmethod:: current_task(loop=None)
837840

@@ -841,7 +844,8 @@ Task Object
841844
is used to get the current loop.
842845

843846
This method is **deprecated** and will be removed in
844-
Python 3.9. Use the :func:`current_task` function instead.
847+
Python 3.9. Use the :func:`asyncio.current_task` function
848+
instead.
845849

846850

847851
.. _asyncio_generator_based_coro:

0 commit comments

Comments
 (0)
X Tutup