GeezerVison is showing github.com — Adopt Py3.8+ features: Names for asyncio tasks · Issue #3733 · python-telegram-bot/python-telegram-bot
Adopt Py3.8+ features: Names for asyncio tasks #3733
Description
Python 3.8 adds a name argument to the function asyncio.create_task. This allows to give all tasks an interpretable name, which can help with debugging and also provides more transparency for users.
We should
- revisit our code base to check all uses of
asyncio.create_task and provide meaningful names
- if possible, also extend the unit tests to assert that the name is set on the tasks. I'm not entirely sure if that's possible
A PR in this direction is very welcome. As long as #3728 is open, it should be based on the drop-py-37 branch. If you would like to send a PR, please be sure to read our contribution guide and leave a short comment so that we can assign you.
Activity
Trifase commented on Jun 4, 2023
Seems to me that asyncio.create_task is called only 4 times in the whole code (3 in telegram.ext._application.py and 1 in telegram.ext._updater.py) except for tests.
I don't think that tasks in tests need to be named, to be honest...
Furthermore, it's possible to get the name of a task using get_name() and assert it, but it's really necessary?
Bibo-Joshi commented on Jun 6, 2023
I don't think that tasks in tests need to be named, to be honest...
True
Furthermore, it's possible to get the name of a task using get_name() and assert it, but it's really necessary?
In general, tests should cover every behavior that we want to protect from regression and in particular this includes any documented behavior. I agree that naming of the internal tasks is not necessary to document and probably hard to test, so I'm fine with skipping that.
Another thought that I had is that we can add the name argument to our Application.create_task wrapper. It should be a keyword-only argument as in the std-lib. This must however be tested :)
Metadata
Metadata
Development
No branches or pull requestsIssue actions