-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
create_task(name=...)
silently fails to set name with custom task_factory after gh-128308
#132593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @sergiosacj Yes, from #128308 on, the The name setting operation is actually done in the C function during calling And by the way, from the code you supplied, the function So, you could get correct name |
Thanks @kthreadd, I misinterpreted then. When I read the documentation, I thought set_name should be called in this scenario. Maybe the sentence below should be updated? "If name is not None, it is set as the name of the task using Task.set_name()"
That's right, this code assumed that set_name was called inside create_task. I made this example based on this test here. |
@sergiosacj, ok, I also noticed that the out of date description in document asyncio.create_task, for the same, test case is also out of date test_set_task_name Both of them need to be updated I believe. |
We tracked the more general issue in #133745. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
During a rebuild of all packages in Debian unstable, the uvloop test suite failed due to a new behavior in asyncio.
This suite runs each test twice: once with uvloop implementation (which passes) and once with Python’s asyncio implementation (which fails).
Since
asyncio.BaseEventLoop.create_task()
no longer callsset_name(name)
. This breaks compatibility with any factory that does not set the name manually.Expected behavior
When using
create_task(..., name="example name")
, the task's name should always be set - even when using a custom task factory - as it was before the regression.Actual behavior
With a custom factory that returns a
subclassed asyncio.Task
, the task name isNone
unless the factory manually callsset_name(name)
. This is a silent behavioral change that breaks code relying onset_name()
being called by the event loop.My Environment
Python version: 3.13.2
Debian testing
Script to reproduce
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: