[issue24495] asyncio.ensure_future() AttributeError with “async def” coroutines
New submission from Martin Panter: While trying to port the example at https://docs.python.org/3.5/library/asyncio-task.html#example-future-with-run-until-complete to use “async def”, I discovered the ensure_future() function does not like the coroutine field name changes introduced in Issue 24400: asyncio.ensure_future(slow_operation(future)) Traceback (most recent call last): File stdin, line 1, in module File /home/proj/python/cpython/Lib/asyncio/futures.py, line 196, in __repr__ info = self._repr_info() File /home/proj/python/cpython/Lib/asyncio/tasks.py, line 105, in _repr_info coro = coroutines._format_coroutine(self._coro) File /home/proj/python/cpython/Lib/asyncio/coroutines.py, line 242, in _format_coroutine filename = coro.gi_code.co_filename AttributeError: 'coroutine' object has no attribute 'gi_code' I understand the gi_ names all changed to cr_, so I guess this code has to adjust as well. -- components: asyncio messages: 245727 nosy: gvanrossum, haypo, vadmium, yselivanov priority: normal severity: normal stage: needs patch status: open title: asyncio.ensure_future() AttributeError with “async def” coroutines type: behavior versions: Python 3.5, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24495 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24495] asyncio.ensure_future() AttributeError with “async def” coroutines
STINNER Victor added the comment: It's not the first time that a bug in found in _format_coroutine(). We need more unit tests! Previous bug: https://github.com/python/asyncio/issues/222 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24495 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24495] asyncio.ensure_future() AttributeError with “async def” coroutines
Yury Selivanov added the comment: Should be fixed now. Thanks for discovering this, Martin! Victor, I'll make a PR on github/asyncio with some refactoring or CoroWrapper etc. The code became too cumbersome, and has to be properly refactored. At least we should have one wrapper class for generator based coroutines, and another one for 'async def' ones. -- resolution: - fixed stage: needs patch - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24495 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24495] asyncio.ensure_future() AttributeError with “async def” coroutines
Roundup Robot added the comment: New changeset 8f4e738cb07f by Yury Selivanov in branch '3.5': Issue #24495, #24400: Test asyncio.Task.repr in debug mode https://hg.python.org/cpython/rev/8f4e738cb07f -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24495 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com