@@ -257,7 +257,7 @@ Creating Tasks
257
257
.. note ::
258
258
259
259
: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 >`_
261
261
that allows for waiting for a group of related tasks with strong safety guarantees.
262
262
263
263
.. important ::
@@ -461,10 +461,14 @@ Running Tasks Concurrently
461
461
462
462
.. note ::
463
463
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.
468
472
469
473
.. _asyncio_example_gather :
470
474
0 commit comments