Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ Creating tasks
# completion:
task.add_done_callback(background_tasks.discard)

Note that this approach never awaits the tasks, so if a task
fails, its exception is never retrieved and asyncio logs a
"Task exception was never retrieved" message when the task is
garbage collected. To avoid this, use :class:`asyncio.TaskGroup`
which keeps a strong reference to each task, awaits them and
propagates their exceptions::

async with asyncio.TaskGroup() as tg:
for i in range(10):
tg.create_task(some_coro(param=i))

.. versionadded:: 3.7

.. versionchanged:: 3.8
Expand Down
Loading