python/cpython · error · TypeError

An asyncio.Future, a coroutine or an awaitable is required

Error message

An asyncio.Future, a coroutine or an awaitable is required

What it means

Error "An asyncio.Future, a coroutine or an awaitable is required" thrown in python/cpython.

Source

Thrown at Lib/asyncio/runners.py:104

        return self._loop

    def run(self, coro, *, context=None):
        """Run code in the embedded event loop."""
        if events._get_running_loop() is not None:
            # fail fast with short traceback
            raise RuntimeError(
                "Runner.run() cannot be called from a running event loop")

        self._lazy_init()

        if not coroutines.iscoroutine(coro):
            if inspect.isawaitable(coro):
                async def _wrap_awaitable(awaitable):
                    return await awaitable

                coro = _wrap_awaitable(coro)
            else:
                raise TypeError('An asyncio.Future, a coroutine or an '
                                'awaitable is required')

        if context is None:
            context = self._context

        task = self._loop.create_task(coro, context=context)

        if (threading.current_thread() is threading.main_thread()
            and signal.getsignal(signal.SIGINT) is signal.default_int_handler
        ):
            sigint_handler = functools.partial(self._on_sigint, main_task=task)
            try:
                signal.signal(signal.SIGINT, sigint_handler)
            except ValueError:
                # `signal.signal` may throw if `threading.main_thread` does
                # not support signals (e.g. embedded interpreter with signals
                # not registered - see gh-91880)
                sigint_handler = None

View on GitHub (pinned to bc6749cc3b)

Solutions

  1. Pass a coroutine, Future, or other awaitable to Runner.run(); verify the argument is the result of calling an async function, not the function itself or a non-awaitable value.

When it happens

Trigger: Raised when Runner.run() is given something that is not a Future, coroutine, or awaitable.

Common situations: See trigger scenarios.


AI-assisted analysis of python/cpython@bc6749cc3b (2026-08-14). Data as JSON: /api/errors/e6f58ff78d6426e8. Report an issue: GitHub.