--- id: looptime version: "0.7" license: MIT license_treatment: permissive maintenance: active --- # looptime — Fast-forward asyncio event loop time (in tests) License: permissive · Maintenance: active · Downloads: 305.1K/mo ## 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 above — 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 pip install looptime uv add looptime poetry add looptime ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 305.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio time mocking, asyncio time fast-forward, event loop time control, asyncio sleep testing, fake time asyncio tests, time acceleration testing, asyncio timeout testing, asyncio-testing, time-mocking [View on SkillFed](https://skillfed.io/packages/looptime) · [View on PyPI](https://pypi.org/project/looptime/)