Vol. 8 — № 24
The Python Loop · KiosqueNewsstand
Blog  
Un atelier Python · Édition d'ApprentissageA Python Workshop · Learning Edition

La coroutine jamais attendue The coroutine that's never awaited

Une coroutine est un objet en attente, pas un calcul en cours — le n°23 l'a montré. La conséquence la plus silencieuse de cette mécanique : coro() sans await ne s'exécute jamais, sans la moindre erreur bruyante. Et une tâche créée avec create_task, sans référence gardée quelque part, peut disparaître avant même d'avoir eu la chance de tourner. A coroutine is a waiting object, not a computation in progress — issue №23 showed that. The most silent consequence of that mechanic: coro() without await never runs, with no loud error at all. And a task created with create_task, with no reference kept anywhere, can vanish before it ever gets the chance to run.

AudienceAudience
Dev qui a vu RuntimeWarning: coroutine was never awaited dans ses logs et qui l'a ignoré Dev who's seen RuntimeWarning: coroutine was never awaited in their logs and ignored it
Format
Self-paced
ChapitresChapters
5
Date
Juil 2026 Jul 2026
≈ 19 min ●●●● asyncioCoroutinesTasks

Chapitre 1 en accès libre — la suite (ch. 2 à 5) est réservée. Chapter 1 free to read — the rest (ch. 2–5) is members-only.

01CadrageFraming3 min

Appeler une coroutine sans await ne l'exécute pas à moitié — elle ne s'exécute pas du tout.Calling a coroutine without await doesn't half-run it — it doesn't run at all.

Le numéro précédent l'a établi : appeler une fonction async def crée un objet coroutine en attente, sans exécuter son corps. La conséquence directe, et la plus silencieuse de toute la série, est celle-ci : si ce coro() n'est jamais donné à await, à asyncio.gather, ou à asyncio.create_task, l'objet reste en attente pour toujours — son corps ne s'exécute JAMAIS, ni maintenant, ni plus tard. Aucune exception n'est levée. Le seul signal est un RuntimeWarning affiché sur stderr, facile à noyer dans des logs bruyants, qui dit littéralement ce qui s'est passé : « coroutine was never awaited ».The previous issue established it: calling an async def function creates a waiting coroutine object without running its body. The direct, and most silent, consequence in this entire series is this: if that coro() is never handed to await, to asyncio.gather, or to asyncio.create_task, the object stays waiting forever — its body NEVER executes, not now, not later. No exception is raised. The only signal is a RuntimeWarning printed to stderr, easy to drown in noisy logs, which literally says what happened: 'coroutine was never awaited'.

Le corps de la coroutine ne s'exécute jamais -- ni le print, ni l'écriture en baseThe coroutine's body never runs -- not the print, not the database write
import asyncio

async def enregistrer_evenement(nom):
    print(f"écriture de {nom} en base...")
    await asyncio.sleep(0.1)
    print(f"{nom} enregistré")

async def main():
    enregistrer_evenement("connexion_utilisateur")   # PAS de await ici
    print("suite du programme")

asyncio.run(main())
# affiche seulement :
# suite du programme
# fichier.py:N: RuntimeWarning: coroutine 'enregistrer_evenement' was never awaited
#
# "écriture de connexion_utilisateur en base..." ne s'affiche JAMAIS --
# le corps de la coroutine n'a tout simplement pas commencé à s'exécuter.
Le réflexe du numéroThis issue's reflex

Un RuntimeWarning: coroutine was never awaited n'est jamais du bruit à ignorer — c'est le signalement exact d'un morceau de code qui n'a jamais tourné.A RuntimeWarning: coroutine was never awaited is never noise to ignore — it's the exact report of a piece of code that never ran.

🔒

La suite est réservée The rest is members-only

Le premier numéro est libre. Débloque tout The Python Loop — tous les volumes, à vie — pour 5 €, paiement unique. The first issue is free. Unlock all of The Python Loop — every volume, forever — for €5, one-time.

Retour au kiosqueBack to newsstand