RuntimeWarning: coroutine was never awaited, explained

Read the explanation
What if

main calls save("a") without await. That only builds a coroutine object, so none of save's code runs, and Python warns when the object is thrown away.

0123456main task: save("a"): a coroutine objectsave("a")main task: RuntimeWarning: never awaitedwarnsmain task: await save("b")save("b")main task: asyncio.sleep(0.01)sleepmain task: print saved bprintprint donecreated, never run

Tap any block to see what that thread is doing.

  • Running
  • Error
  • Waiting on I/O
  • Skipped
Step 1/4

main calls save("a") without await. That only builds a coroutine object: none of save's code runs.

1async def save(item):2    await asyncio.sleep(0.01)  # a database write, say3    print(f"saved {item}")4 5async def main():6    save("a")  # forgot await: makes a coroutine, runs none of it7    await save("b")8    print("done")9 10if __name__ == "__main__":11    asyncio.run(main())

Explanation

What just happened

save("a") without await only built a coroutine object. None of save’s code ran. Nothing kept the object, so Python threw it away at the end of the line and warned: coroutine 'save' was never awaited. The program carried on, and saved a never printed.

Try the what-if switch

Why

An async function is a recipe, not a call: calling it hands you the recipe. Something has to run it, either await here and now, or the event loop, once you make it a task.

How to fix it

Find the line the warning points at and add await. If you meant it to run in the background, use asyncio.create_task(...) and keep the task, so you can await it later.

Watch out

Because it’s only a warning, the bug can hide in logs: the work just never happens. It’s the async cousin of blocking the event loop with time.sleep.

Common questions

What does coroutine was never awaited mean?

You called an async function without await. That only creates a coroutine object and runs none of its code; when the unused object is thrown away, Python warns.

Does the missing await crash the program?

No. It's a warning, not an exception: the rest of the program runs and exits with code 0. Even with -W error, Python only reports it as "Exception ignored" and carries on.

Should I use await or asyncio.create_task?

await runs the coroutine to the end before moving on. asyncio.create_task runs it alongside the current code, starting at the next await; keep the task and await it before you rely on its result.

When exactly is the warning printed?

When the coroutine object is thrown away. For a call whose result nobody keeps, that is right after the line, not at the end of the program.

Verified: this timeline matches a real program, checked in CI on Python 3.14, 3.15 and free-threaded 3.15t. How we verify. Unclear or wrong? Tell us