تخطَّ إلى المحتوى

Async Error Swallowed (ARCH2169)

هذا المحتوى غير متوفر بلغتك بعد.

Key python.logging.async-error-swallowed · Severity warning · Category logging

Unawaited coroutines and fire-and-forget tasks let the exceptions inside them vanish silently. The task fails but it is never noticed or logged anywhere.

async def handle(req):
asyncio.create_task(send_notification(req))
return ok()
async def handle(req):
task = asyncio.create_task(send_notification(req))
task.add_done_callback(
lambda t: t.exception() and logger.error("Notification failed", exc_info=t.exception())
)
return ok()

Await the task, or attach a done-callback that catches and logs the exception.