Skip to content

Commit 2ec30ca

Browse files
committed
Extra docs for ExtraTaskGroup
1 parent 6310a3b commit 2ec30ca

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,31 @@ With ExtraTaskGroup, all created tasks are run to completion,
4747
and any exceptions are bubbled up as ExceptionGroups on
4848
the host task.
4949

50+
It is not that extraasync dislikes the idea of
51+
structured concurrency by Nataniel Smith's Trio -
52+
if a child task does fail, the taskgroup will still
53+
wait for all others to finish before propagating that error:
54+
it just won't cancel the siblings, and allow then to run to
55+
conclusion! (check https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/#what-is-a-goto-statement-anyway to learn more)
56+
57+
Just put the `async with ExtraTaskGroup():` statement
58+
inside a try except block, to catch, as an exception group,
59+
all exceptions that were raised in that block's tasks.
60+
61+
The one reason I believe Nataniel opted for
62+
cancelling siblings by default is that
63+
for _long_term_ nuseries, like a server
64+
which will spawn tasks for handling clients,
65+
the exception and traceback objects will pile
66+
up, and that would be a resource leak - please,
67+
use some fine-grained, in task, error handling for
68+
anything other than "a bunch of tasks, and alright if some fail".
69+
(Nataniel's trio has the concept of retrying groups - those
70+
might come in the future as other constructs to extraasync -
71+
the differentiak to Trio is that extraasync will remain
72+
compatible with Python stdlib's asyncio)
73+
74+
5075
```python
5176
import asyncio
5277

0 commit comments

Comments
 (0)