Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
The classasyncio.Runner currently checks explicitly that its coro argument is a coroutine:
cpython/Lib/asyncio/runners.py
Lines 87 to 89 in46e69f8
| """Run a coroutine inside the embedded event loop.""" | |
| ifnotcoroutines.iscoroutine(coro): | |
| raiseValueError("a coroutine was expected, got {!r}".format(coro)) |
However, shouldn't this allow any awaitable, checked viainspect.isawaitable(), or perhaps aligned withrun_until_complete(), which currently accepts aFuture object? Is there a specific reason why only coroutines are allowed here?
I've got a class which implements a custom__await__() method that I'd like to be able to pass into asyncio.Runner, but the check above is preventing this. There are workaround for this, like wrapping the await on the object in a regular async function, but I'd prefer not to require that.
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Done