How can you wait for multiple tasks but proceed as soon as the first one completes?
Python interview question for Advanced practice.
Answer
asyncio.wait(tasks, returnwhen=asyncio.FIRSTCOMPLETED)
Explanation
asyncio.wait() with FIRSTCOMPLETED returns as soon as the first task in the set finishes, returning both 'done' and 'pending' sets.