summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/tasks.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2022-03-23 15:43:05 (GMT)
committerGitHub <noreply@github.com>2022-03-23 15:43:05 (GMT)
commit0360e9f34659e7d7f3dae021b82f78452db8c714 (patch)
treef88f12dd56fb3f0cca5557447835c94fbea12cb5 /Lib/asyncio/tasks.py
parent624e3986fbf8467772e4863b7ec004e65adff619 (diff)
downloadcpython-0360e9f34659e7d7f3dae021b82f78452db8c714.zip
cpython-0360e9f34659e7d7f3dae021b82f78452db8c714.tar.gz
cpython-0360e9f34659e7d7f3dae021b82f78452db8c714.tar.bz2
bpo-46829: Deprecate passing a message into Future.cancel() and Task.cancel() (GH-31840)
After a long deliberation we ended up feeling that the message argument for Future.cancel(), added in 3.9, was a bad idea, so we're deprecating it in 3.11 and plan to remove it in 3.13.
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r--Lib/asyncio/tasks.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index e876f8d..27fe58d 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -207,6 +207,11 @@ class Task(futures._PyFuture): # Inherit Python Task implementation
This also increases the task's count of cancellation requests.
"""
+ if msg is not None:
+ warnings.warn("Passing 'msg' argument to Task.cancel() "
+ "is deprecated since Python 3.11, and "
+ "scheduled for removal in Python 3.14.",
+ DeprecationWarning, stacklevel=2)
self._log_traceback = False
if self.done():
return False