Skip to content

Commit a882de7

Browse files
Addressing comments and taking onboard suggestions from reviewer.
1 parent 6c8e140 commit a882de7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Doc/library/asyncio-task.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Creating Tasks
257257
.. note::
258258

259259
:meth:`asyncio.TaskGroup.create_task` is a new alternative
260-
based on `structural concurrency principles <https://en.wikipedia.org/wiki/Structured_concurrency>`_
260+
based on `structural concurrency principles <https://en.wikipedia.org/wiki/Structured_concurrency>`_
261261
that allows for waiting for a group of related tasks with strong safety guarantees.
262262

263263
.. important::
@@ -461,10 +461,14 @@ Running Tasks Concurrently
461461

462462
.. note::
463463
A new alternative to create and run tasks concurrently and
464-
wait for their completion is :class:`asyncio.TaskGroup`. While *TaskGroup*
465-
provides strong safety guarantees for scheduling a nesting of subtasks, *gather* comes in handy
466-
for tasks that do not schedule subtasks and need to have their results consumed eagerly
467-
(i.e. when destructuring the result(s) into a tuple).
464+
wait for their completion is :class:`asyncio.TaskGroup`. *TaskGroup*
465+
provides stronger safety guarantees than *gather* for scheduling a nesting of subtasks.
466+
That is, if a task (or a subtask, a task scheduled by a task)
467+
raises an exception, *TaskGroup* will, while *gather* will not,
468+
cancel the remaining scheduled tasks). However the terser *gather* might be
469+
preferred for *Iterable* of tasks which individually handle their own exceptions, or more
470+
generally, when having some tasks survive the cancellation
471+
of others is an acceptable outcome.
468472

469473
.. _asyncio_example_gather:
470474

0 commit comments

Comments
 (0)