Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #8267/509fb269 backport][3.9] Add note about tasks that should be cancelled on shutdown #8268

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES/8267.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a note about canceling tasks to avoid delaying server shutdown -- by :user:`Dreamsorcerer`.
8 changes: 8 additions & 0 deletions docs/web_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,14 @@ steps 4 and 7).
:ref:`cleanup contexts<aiohttp-web-cleanup-ctx>`.
7. Cancel any remaining tasks and wait on them to complete.

.. note::

When creating new tasks in a handler which _should_ be cancelled on server shutdown,
then it is important to keep track of those tasks and explicitly cancel them in a
:attr:`Application.on_shutdown` callback. As we can see from the above steps,
without this the server will wait on those new tasks to complete before it continues
with server shutdown.

Websocket shutdown
^^^^^^^^^^^^^^^^^^

Expand Down
Loading