WarningPython Error

RuntimeWarning

RuntimeWarning: coroutine 'func' was never awaited

Traceback

terminal
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    data = fetch_data()  # coroutine never awaited!
RuntimeWarning: coroutine 'func' was never awaited

What causes this error

An async function was called without `await`, creating a coroutine object that was never executed. The async operation never ran.

How to fix it

Add `await` before the async function call. Use `asyncio.run()` from synchronous code. Schedule with `asyncio.create_task()` for concurrent execution. Ensure the calling function is also async.

Code that causes this error

Broken
async def fetch_data():
    return {"result": 42}

data = fetch_data()  # coroutine never awaited!

Fixed code

Fixed
import asyncio

async def fetch_data():
    return {"result": 42}

async def main():
    data = await fetch_data()
    print(data)

asyncio.run(main())

About RuntimeWarning

This RuntimeWarning occurs when an async function (coroutine) is called but the result is never awaited. Calling an async function does not execute it — it creates a coroutine object. To actually run the coroutine, you must `await` it from another async function, pass it to `asyncio.run()`, or schedule it with `asyncio.create_task()`.

This is one of the most common mistakes when learning async Python: forgetting that `async_func()` does not execute the function. The warning appears at garbage collection time when the unawaited coroutine is cleaned up. While technically a warning, it almost always indicates a bug — the async operation you intended to perform never ran.

Enabling Python's warning system with `-W error::RuntimeWarning` turns this into a hard error for easier debugging.

Common scenarios

1

Using deprecated APIs that will be removed in future versions

2

Performing numerical operations that produce inf or NaN values

3

Leaving files, sockets, or connections open without proper cleanup

4

Calling async functions without awaiting the result

Related errors