Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

asyncio.Runner explicitly checks for coroutine #120284

Closed
Labels
@ronf

Description

@ronf

The classasyncio.Runner currently checks explicitly that its coro argument is a coroutine:

"""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

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp