async def f(): raise RuntimeError("oops") async def main(): asyncio.create_task(f()) await asyncio.sleep(0.05) print("ok") asyncio.run(main())