Registry / testing / looptime

looptime

JSON →
library0.7pypypi✓ verified 80d ago

Utility to fast-forward asyncio event loop time for deterministic testing. Current version 0.7, requires Python >=3.10. Released as a standalone package to replace pytest-asyncio's `loop_context` for controlling virtual time.

pip install looptime
INSTALL
IMPORT
SIG · LOOPTIME
L
looptime
testingpythonv0.7
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Chronometer
from looptime import Chronometer
from looptime import Looper
LoopTimeEventLoop
from looptime import LoopTimeEventLoop
new_event_loop
from looptime import new_event_loop

Basic usage: create a Looper, enter it as a context manager, advance time, and exit.

import asyncio from looptime import Looper async def test_sleep(): looper = Looper() asyncio.get_event_loop().run_until_complete(looper.__aenter__()) await asyncio.sleep(3600) # Without looper, this would block for an hour. looper.advance(3600) # Now the sleep completes immediately. await looper.__aexit__(None, None, None)
Debug
Known issues
gotchaLooper must be used as a context manager (async with). Simply creating a Looper instance without entering will not affect event loop timing.
fix
Use 'async with Looper() as looper:' to ensure the looper is properly activated.
affects: all
gotchaAdvancing time via looper.advance() does not automatically wake up tasks; it only moves the clock. Tasks waiting on asyncio.sleep() will only resume when the looper's event loop cycle runs (e.g., after the advance call returns).
fix
After calling advance(), await asyncio.sleep(0) to yield control and allow scheduled tasks to run.
affects: all
Upgrade
Version history
0.7latest on PyPI · released Jan 3, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
looptime — pip install looptime · libregistry