◐ Shell
clean mode source ↗

Message 256535 - Python tracker

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