I have a variable number of long running tasks created with asyncio.create_task(). I would like to gracefully exit my program immediately if any of these tasks raises an exception. I cannot asyncio.wait() the tasks since not all tasks are created at the same time (some running tasks create new tasks at varying times as required).
My thinking is to use Task.add_done_callback() to be notified when tasks complete, but the Python documentation suggests this should be used for low-level callback code only, is there an alternative?