aiotools icon indicating copy to clipboard operation
aiotools copied to clipboard

Eventloop get stuck when VirtualClock used with real timestamps

Open KholdStare opened this issue 5 months ago • 0 comments

When using real timestamps for like 1709591365, the python event loop gets stuck forever in await:

import pytest
import asyncio
from aiotools import VirtualClock

@pytest.mark.asyncio
async def test_stuck_forever():
  clock = VirtualClock()
  clock.vtime = 1709591365
  with lock.patch_loop():
    await asyncio.sleep(1)

This is due to a behavior (bug?) in the BaseEventLoop https://github.com/python/cpython/issues/116342 .

The way I was able to solve it, was to override the eventloop _clock_resolution to 0.1 . Perhaps this should be added to the patch_loop implementation?

KholdStare avatar Mar 04 '24 23:03 KholdStare