Strange behavior of asyncio in 3.6

82 views
Skip to first unread message

Alberto Berti

unread,
Jan 13, 2017, 12:21:34 PM1/13/17
to python...@googlegroups.com
Hi,

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]

Thanks in advance,

Alberto

Guido van Rossum

unread,
Jan 13, 2017, 4:12:49 PM1/13/17
to Alberto Berti, python-tulip
Can you file a bug in the CPython tracker for this? bugs.python.org.
--
--Guido van Rossum (python.org/~guido)

Yury Selivanov

unread,
Jan 13, 2017, 5:12:05 PM1/13/17
to Guido van Rossum, Alberto Berti, python-tulip
Yes, this is a bug, and looks like Task.all_tasks() has the same problem. I’ve created a bug to track the issue: http://bugs.python.org/issue29271

Yury

Alberto Berti

unread,
Jan 13, 2017, 5:26:04 PM1/13/17
to python...@googlegroups.com
>>>>> "Yury" == Yury Selivanov <yseli...@gmail.com> writes:

Yury> Yes, this is a bug, and looks like Task.all_tasks() has the
Yury> same problem. I’ve created a bug to track the issue:
Yury> http://bugs.python.org/issue29271

Ah, you beat me,

thanks.

Alberto

Reply all
Reply to author
Forward
0 new messages