From 0ee73c57e716d5756f7fb4243695dbdb13709cf7 Mon Sep 17 00:00:00 2001 From: Felix Scherz Date: Thu, 10 Apr 2025 19:47:40 +0200 Subject: [PATCH 1/5] docs: document return values for asyncio.Task.cancel --- Doc/library/asyncio-task.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index b6ae443860843b..b8e4ec5620a597 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -1381,7 +1381,11 @@ Task Object Request the Task to be cancelled. - This arranges for a :exc:`CancelledError` exception to be thrown + If the Task is already *done* or *cancelled*, return ``False``. + Otherwise, change the Task's state to *cancelled*, + schedule the callbacks, and return ``True``. + + The method arranges for a :exc:`CancelledError` exception to be thrown into the wrapped coroutine on the next cycle of the event loop. The coroutine then has a chance to clean up or even deny the From 07a9ce981ae2a12f508da0096c508e27f131a2c3 Mon Sep 17 00:00:00 2001 From: Felix Scherz Date: Thu, 10 Apr 2025 19:56:31 +0200 Subject: [PATCH 2/5] chore: update ACKS --- Misc/ACKS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/ACKS b/Misc/ACKS index 814a530f7b79d4..3cd768e405af6d 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1662,6 +1662,7 @@ Andreas Schawo Neil Schemenauer David Scherer Wolfgang Scherer +Felix Scherz Hynek Schlawack Bob Schmertz Gregor Schmid From e039f42546d2a5dedbba5578c89ec4747c199a75 Mon Sep 17 00:00:00 2001 From: Felix Scherz Date: Thu, 10 Apr 2025 20:42:09 +0200 Subject: [PATCH 3/5] chore: add blurb --- .../Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst diff --git a/Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst b/Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst new file mode 100644 index 00000000000000..309f28bee8a128 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst @@ -0,0 +1 @@ +Document return value for :func:`asyncio.Task.cancel`. From 01bf3b6487278e62f328efc0c61c84a99cf71c6e Mon Sep 17 00:00:00 2001 From: Felix Scherz Date: Thu, 10 Apr 2025 22:13:22 +0200 Subject: [PATCH 4/5] Revert "chore: add blurb" This reverts commit e039f42546d2a5dedbba5578c89ec4747c199a75. --- .../Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst diff --git a/Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst b/Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst deleted file mode 100644 index 309f28bee8a128..00000000000000 --- a/Misc/NEWS.d/next/Documentation/2025-04-10-20-41-53.gh-issue-132354.GN6DcP.rst +++ /dev/null @@ -1 +0,0 @@ -Document return value for :func:`asyncio.Task.cancel`. From 402c79bc567202d479df41a2b932661ee87bb649 Mon Sep 17 00:00:00 2001 From: Felix Scherz Date: Sat, 12 Apr 2025 21:04:21 +0200 Subject: [PATCH 5/5] docs: simplify description --- Doc/library/asyncio-task.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index b8e4ec5620a597..59acce1990ae04 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -1381,9 +1381,8 @@ Task Object Request the Task to be cancelled. - If the Task is already *done* or *cancelled*, return ``False``. - Otherwise, change the Task's state to *cancelled*, - schedule the callbacks, and return ``True``. + If the Task is already *done* or *cancelled*, return ``False``, + otherwise, return ``True``. The method arranges for a :exc:`CancelledError` exception to be thrown into the wrapped coroutine on the next cycle of the event loop.