Issue 29271: Task.current_task(None) returns unexpected result (original) (raw)

Issue29271

Created on 2017-01-13 22:11 by yselivanov, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
task.patch yselivanov,2017-01-13 22:17 review
Pull Requests
URL Status Linked Edit
PR 406 merged yselivanov,2017-03-02 22:35
PR 413 merged yselivanov,2017-03-03 03:25
PR 703 larry,2017-03-17 21:00
PR 552 closed dstufft,2017-03-31 16:36
Messages (6)
msg285445 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-01-13 22:11
Quoting Alberto Berdi from python-tulip mailing list: working with the Python 3.6 asyncio implemented in C, i've got what is for me a strange behavior of the asyncio.Task.current task function. Executing the following test: import asyncio async def coro(): print(asyncio.Task.current_task()) print(asyncio.Task.current_task(None)) print(asyncio.Task.current_task(loop=asyncio.get_event_loop())) loop = asyncio.get_event_loop() loop.run_until_complete(coro()) in Py3.5, I obtain the result: <Task pending coro=<coro() running at test_task.py:4> cb=[_run_until_complete_cb() at /usr/lib/python3.5/asyncio/base_events.py:176]> <Task pending coro=<coro() running at test_task.py:5> cb=[_run_until_complete_cb() at /usr/lib/python3.5/asyncio/base_events.py:176]> <Task pending coro=<coro() running at test_task.py:6> cb=[_run_until_complete_cb() at /usr/lib/python3.5/asyncio/base_events.py:176]> In Py3.6, i get: <Task pending coro=<coro() running at test_task.py:4> cb=[_run_until_complete_cb() at /usr/lib/python3.6/asyncio/base_events.py:176]> None <Task pending coro=<coro() running at test_task.py:6> cb=[_run_until_complete_cb() at /usr/lib/python3.6/asyncio/base_events.py:176]> What's going on here? It's still right to expect the same result from the three calls or something has changed? The documentation for the Task.current_task() function seems unchanged between the two version. My python3.6 has version: $ python3.6 -VV Python 3.6.0 (default, Dec 29 2016, 04:29:02) [GCC 6.2.1 20161215]
msg285447 - (view) Author: Lele Gaifax (lelit) * Date: 2017-01-13 22:57
FWIW, the problem afflicts other functions, for example the following script exhibits a similar difference: import asyncio async def coro(): print(asyncio.Task.all_tasks()) print(asyncio.Task.all_tasks(None)) loop = asyncio.get_event_loop() loop.run_until_complete(coro())
msg285448 - (view) Author: Lele Gaifax (lelit) * Date: 2017-01-13 23:01
Yay, Yury is too fast!! :-)
msg285456 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017-01-14 02:39
LGTM
msg288855 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-03-03 04:20
New changeset 13802a3b11eb5202b16e464cbfb85c144f8581ce by Yury Selivanov in branch '3.6': bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. (#406) https://github.com/python/cpython/commit/13802a3b11eb5202b16e464cbfb85c144f8581ce
msg290338 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-03-24 23:08
New changeset 8d26aa930c0123933a1ceb12fceba4f5aef4e95e by Yury Selivanov in branch 'master': bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. (#406) https://github.com/python/cpython/commit/8d26aa930c0123933a1ceb12fceba4f5aef4e95e
History
Date User Action Args
2022-04-11 14:58:42 admin set github: 73457
2017-03-31 16:36:33 dstufft set pull_requests: + <pull%5Frequest1062>
2017-03-24 23:08:55 yselivanov set messages: +
2017-03-17 21:00:33 larry set pull_requests: + <pull%5Frequest591>
2017-03-03 23:10:28 yselivanov set status: open -> closedresolution: fixedstage: patch review -> resolved
2017-03-03 04:20:31 yselivanov set messages: +
2017-03-03 03:25:10 yselivanov set pull_requests: + <pull%5Frequest344>
2017-03-02 22:35:14 yselivanov set pull_requests: + <pull%5Frequest338>
2017-01-14 02:39:31 methane set messages: +
2017-01-13 23:01:26 lelit set messages: +
2017-01-13 22:57:20 lelit set messages: +
2017-01-13 22:31:21 gvanrossum set nosy: - gvanrossum
2017-01-13 22:28:00 lelit set nosy: + lelit
2017-01-13 22:26:22 azazel set nosy: + azazel
2017-01-13 22:17:41 yselivanov set files: + task.patchnosy: + methanekeywords: + patch
2017-01-13 22:11:24 yselivanov create