Skip to content

Commit 65ea453

Browse files
Addressing comments and taking onboard suggestions from reviewer.
1 parent 06dd589 commit 65ea453

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Doc/library/asyncio-task.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Creating Tasks
249249
.. note::
250250

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

255255
.. important::
@@ -449,10 +449,14 @@ Running Tasks Concurrently
449449

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

457461
.. _asyncio_example_gather:
458462

0 commit comments

Comments
 (0)