Skip to content

Commit 7e473e9

Browse files
bpo-46995: Deprecate missing asyncio.Task.set_name() for third-party task implementations (GH-31838)
Co-authored-by: Kumar Aditya <[email protected]>
1 parent 3543ddb commit 7e473e9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Lib/asyncio/tasks.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ def _set_task_name(task, name):
6767
try:
6868
set_name = task.set_name
6969
except AttributeError:
70-
pass
70+
warnings.warn("Task.set_name() was added in Python 3.8, "
71+
"the method support will be mandatory for third-party "
72+
"task implementations since 3.13.",
73+
DeprecationWarning, stacklevel=3)
7174
else:
7275
set_name(name)
7376

Lib/test/test_asyncio/test_tasks.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import textwrap
1313
import traceback
1414
import unittest
15-
import weakref
1615
from unittest import mock
1716
from types import GenericAlias
1817

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate missing :meth:`asyncio.Task.set_name` for third-party task
2+
implementations, schedule making it mandatory in Python 3.13.

0 commit comments

Comments
 (0)