aiotools
aiotools copied to clipboard
Eventloop get stuck when VirtualClock used with real timestamps
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?