bpo-46995: Deprecate missing asyncio.Task.set_name() for third-party task implementations (GH-31838)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Andrew Svetlov 2022-03-13 18:34:46 +02:00 committed by GitHub
parent 3543ddb4c4
commit 7e473e94a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View file

@ -67,7 +67,10 @@ def _set_task_name(task, name):
try: try:
set_name = task.set_name set_name = task.set_name
except AttributeError: except AttributeError:
pass warnings.warn("Task.set_name() was added in Python 3.8, "
"the method support will be mandatory for third-party "
"task implementations since 3.13.",
DeprecationWarning, stacklevel=3)
else: else:
set_name(name) set_name(name)

View file

@ -12,7 +12,6 @@ import sys
import textwrap import textwrap
import traceback import traceback
import unittest import unittest
import weakref
from unittest import mock from unittest import mock
from types import GenericAlias from types import GenericAlias

View file

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