looptime
Fast-forward asyncio event loop time (in tests)
What it is and what it does
Looptime is a plugin that intercepts asyncio's internal clock, allowing tests to advance time instantly while the event loop sees the full passage. From the loop's perspective, sleeps, timeouts, and delayed callbacks execute in zero real time; from the observer's perspective, a test that would normally take minutes runs in seconds or less. It was originally built for Kopf, a framework for Kubernetes Operators in Python, where it reduced approximately 7000 unit tests to approximately 2 minutes.
The library does not speed up tests that are slow for reasons unrelated to explicit time delays—such as local network I/O, heavy computation, or data processing. It only compacts asyncio-based timing primitives. It works transparently and can be enabled globally or per-test, with no changes to test code itself.
Use it for:
- Speed up asyncio test suites that use sleeps, timeouts, or rate limiters without breaking time-dependent assertions.
- Test retry logic, exponential backoff, or other delay-based patterns in near-zero real time.
- Verify event loop scheduling and callback ordering without waiting for actual delays.
- Reduce CI/CD pipeline duration for projects with large asyncio test suites.
- Test long-running background tasks or periodic jobs that would otherwise take minutes per test.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Looptime fakes the passage of time in asyncio event loops during tests, allowing time-dependent code to run in near-zero real time while the loop's internal clock advances by configured amounts.
Yes, if you have asyncio-based tests with explicit time delays. Install it for any suite using asyncio that includes sleeps, timeouts, or time-dependent logic—it integrates transparently, has no dependencies, and is actively maintained. Skip it if your tests have no explicit delays or use only synchronous code.
Install
looptime on PyPI
pip
pip install looptimeuv
uv add looptimepoetry
poetry add looptimeInstalling looptime
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-01-03 with recent commits.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.
Quickstart
pip install looptime
import asyncio
await asyncio.sleep(100)
assert asyncio.get_running_loop().time() == 100
Requires Python 3.10 or later.
Verify before relying
- Whether looptime works with all asyncio patterns or only a subset of time-dependent scenarios.
- Performance impact on very large test suites or tests with many concurrent tasks.
- Compatibility with third-party asyncio event loop implementations beyond CPython and PyPy.
- Integration requirements with test frameworks beyond those mentioned in classifiers.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 223 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 305,147/month — #7,797 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: looptime-0.7-py3-none-any.whl
Keywords: asyncio, event loop, time, python, pytest
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
time-machineMocks and freezes time in tests, allowing you…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
asyncmockProvides awaitable mock objects for testing…
permissive · top 15,000 on PyPI
aresponsesMocks external HTTP/HTTPS services for…
permissive · top 15,000 on PyPI
pytest-freezerpytest-freezer provides a pytest fixture that…
permissive · top 5,000 on PyPI
pytest-loopA pytest plugin that repeats tests a fixed…
copyleft · top 15,000 on PyPI
pytest-asyncio-concurrentA pytest plugin that executes async test…
permissive · top 15,000 on PyPI
aiocopDetects and logs blocking I/O and CPU calls in…
permissive · top 15,000 on PyPI
loop-rate-limitersProvides synchronous and asynchronous rate…
permissive · top 15,000 on PyPI
waiterWaiter provides iteration-based retry and…
permissive · top 15,000 on PyPI