Skip to content

Commit 46438be

Browse files
committed
Tutorial: Improve Task Groups section.
1 parent cbb97f4 commit 46438be

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

v3/docs/TUTORIAL.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,10 @@ The `TaskGroup` class is unofficially provided by
862862
suited to applications where one or more of a group of tasks is subject to
863863
runtime exceptions. A `TaskGroup` is instantiated in an asynchronous context
864864
manager. The `TaskGroup` instantiates member tasks. When all have run to
865-
completion, the context manager terminates. Return values from member tasks
866-
cannot be retrieved. Results should be passed in other ways such as via bound
867-
variables, queues etc.
865+
completion, the context manager terminates. Where `gather` is static, a task
866+
group can be dynamic: a task in a group may spawn further group members. Return
867+
values from member tasks cannot be retrieved. Results should be passed in other
868+
ways such as via bound variables, queues etc.
868869

869870
An exception in a member task not trapped by that task is propagated to the
870871
task that created the `TaskGroup`. All tasks in the `TaskGroup` then terminate
@@ -922,6 +923,9 @@ async def main():
922923

923924
asyncio.run(main())
924925
```
926+
[This doc](https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/)
927+
provides background on the theory behind task groups and how they can improve
928+
program structure and reliablity.
925929

926930
###### [Contents](./TUTORIAL.md#contents)
927931

0 commit comments

Comments
 (0)