Message 260203 - Python tracker (original) (raw)

I haven't looked at the patch, but the intent to make the 2nd await raise a RuntimeError seems strange for several reasons:

Well, coroutines are much more lower level than Future/Tasks.

I believe you're not using the asyncio.task() function correctly.
From the docs:

"""Wait for the Futures and coroutine objects given by the sequence futures to complete. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending)."""

Yes, this was discussed at length on the mailing list. There are many reasons as to why we don't want coroutines to be awaitable many times. One of them is that we don't want low-level coroutine objects to hold references to return values. Coroutines in Python are exhaustible resources (like generators).