Total Wall-Clock Time of Concurrent Sleeps
import asyncio
import time
async def worker(delay):
await asyncio.sleep(delay)
async def main():
start = time.perf_counter()
await asyncio.gather(worker(1), worker(0.2), worker(0.2))
return time.perf_counter() - start
elapsed = asyncio.run(main())
print(round(elapsed))
The three worker calls sleep for 1, 0.2, and 0.2 seconds. What single integer does this print (the elapsed time rounded to the nearest second)?
Sign in to answer questions and track your progress
Sign In