KITFORMA · EDITORIAL ANSWER
When should TaskGroup replace a group of unrelated background tasks?
KitForma editorial guide. Use a task group when child operations belong to one lifetime and failures should be coordinated. Python 3.11 introduced `asyncio.TaskGroup` for this structured ownership.
Step-by-step answer
asyncio.TaskGroup for this structured ownership.
Create related tasks inside async with asyncio.TaskGroup() as group: and let the context wait for them. Test one child failing while another is waiting, and verify cleanup and exception handling. TaskGroup can raise an exception group, so error handling differs from catching a single ordinary exception. It is not a persistent job queue and does not survive process restarts. Work that must outlive a request needs durable ownership outside that request’s task group.Sources and verification
Sources checked:
Scope: This editorial guide is based on the cited sources and tool behavior. A forum question or a query observed for our site does not establish market search volume, low competition, guaranteed rankings or inadequate answers elsewhere.
This editorial answer was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.