From 00c0224c3a38107df01939f2a76f7118ec2b751d Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 29 Mar 2024 23:05:02 +0000 Subject: [PATCH 1/3] Add note about tasks that should be cancelled on shutdown --- docs/web_advanced.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/web_advanced.rst b/docs/web_advanced.rst index 5ba3cd33442..f4c19a7c946 100644 --- a/docs/web_advanced.rst +++ b/docs/web_advanced.rst @@ -956,6 +956,14 @@ steps 4 and 7). :ref:`cleanup contexts`. 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 ^^^^^^^^^^^^^^^^^^ From a854ebf9531f3a370fb427c82fe5b6e5b7ed5946 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 29 Mar 2024 23:08:06 +0000 Subject: [PATCH 2/3] Create 8267.doc.rst --- CHANGES/8267.doc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/8267.doc.rst diff --git a/CHANGES/8267.doc.rst b/CHANGES/8267.doc.rst new file mode 100644 index 00000000000..76f9b76a0dd --- /dev/null +++ b/CHANGES/8267.doc.rst @@ -0,0 +1 @@ +Added a note about cancelling tasks to avoid delaying server shutdown -- by :user:`Dreamsorcerer`. From 8422bd605c01d8744929f63e11e287805e1c405b Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 29 Mar 2024 23:32:54 +0000 Subject: [PATCH 3/3] Update 8267.doc.rst --- CHANGES/8267.doc.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES/8267.doc.rst b/CHANGES/8267.doc.rst index 76f9b76a0dd..69f11d37560 100644 --- a/CHANGES/8267.doc.rst +++ b/CHANGES/8267.doc.rst @@ -1 +1 @@ -Added a note about cancelling tasks to avoid delaying server shutdown -- by :user:`Dreamsorcerer`. +Added a note about canceling tasks to avoid delaying server shutdown -- by :user:`Dreamsorcerer`.