[issue25887] awaiting on coroutine more than once should be an error

Yury Selivanov report at bugs.python.org
Wed Dec 16 16:46:57 EST 2015


New submission from Yury Selivanov:

async def foo():
    return 123

print(await foo())   # will print 123
print(await foo())   # prints None
print(await foo())   # prints None


The above code illustrates the current behaviour.  I propose to change it, so that second 'await' will trigger a RuntimeError, explaining the the coroutine was awaited more than once.

This would make coroutines more predictable, and would allow users to catch subtle bugs in their code.

This topic was originally brought up in this thread: https://mail.python.org/pipermail/python-dev/2015-December/142443.html

----------
assignee: yselivanov
components: Interpreter Core
messages: 256535
nosy: asvetlov, gvanrossum, haypo, ncoghlan, yselivanov
priority: normal
severity: normal
status: open
title: awaiting on coroutine more than once should be an error
type: enhancement
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25887>
_______________________________________


More information about the Python-bugs-list mailing list