为什么 asyncio.sleep(delay) 比给定的延迟更早完成?

Why asyncio.sleep(delay) completes earlier than given delay?

import asyncio, aiohttp, logging, time, random

pause = 1/10

async def req(i):
    await asyncio.sleep(random.randint(1, 5))

async def run():
    for i in range(100):
        asyncio.ensure_future(req(i))
        t0 = time.time()
        await asyncio.sleep(pause)
        print(time.time() - t0)
    tasks = asyncio.Task.all_tasks()
    if len(tasks) != 1:
        tasks.remove(asyncio.Task.current_task())
        await asyncio.wait(tasks)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())

输出为:

为什么 await asyncio.sleep(暂停)在 0.093654 秒后完成??????????

它是 Windows 上的 bug/feature asyncio。您可以阅读讨论 here.