Skip to main content

timeless_loop

timeless_loop is a Python library that provides a custom asyncio event loop, allowing you to freeze time and avoid pesky delays while writing or testing async code. It does so by defining a subclass of the standard library SelectorEventLoop, which behaves nearly identically to the real one. It differs in that it does not actually wait for any time to pass; instead, it simply advances the loop's internal clock to the exact time of execution of the next scheduled callback when there are no immediately ready loop callbacks available. This allows you to run code that uses asyncio's sleep and wait functions without having to wait for the actual time to pass, without having to change any lines of code between the real and the fake time event loop.

Installation

timeless_loop is available on PyPI and can be installed with poetry, pip, or your favorite package manager.

pip install timeless_loop

Usage

The recommended way of setting the TimelessEventLoop is through setring the loop policy with asyncio.set_event_loop_policy. It can be used as follows:

import asyncio

async def main():
    # code here will run on the TimelessEventLoop
    pass

if __name__ == "__main__":
    
    
    # Set the event loop policy to use the TimelessEventLoop
    from timeless_loop import TimelessEventLoopPolicy
    
    asyncio.set_event_loop_policy(TimelessEventLoopPolicy())
    asyncio.run(main())
    
    # OR:
    # Use the context manager:
    import timeless_loop
    
    with timeless_loop:
        asyncio.run(main())

License

timeless_loop is licensed under the MIT License. See the LICENSE file for more details.

Release files for timeless-loop 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for timeless-loop 0.2.0
File Size Uploaded
timeless_loop-0.2.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for timeless-loop 0.2.0
File Interpreter ABI Platform
timeless_loop-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / timeless_loop-0.2.0.tar.gz

Download URL timeless_loop-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
35570ef6e97ede236d440ead0705c9f38514d4a69eb8350794c128b37365dac2
BLAKE2b-256 checksum
How to use checksums
b73e754ebfcf469c66887e944cf04e3b6c9a346388aca3aa2bfe746a600add32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.0 CPython/3.10.11 Linux/6.1.36

Release files / timeless_loop-0.2.0-py3-none-any.whl

Download URL timeless_loop-0.2.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
830e0219d3e20c28bb578a5ba56ed49ed8fa4424644b728d1315839c67f1e51e
BLAKE2b-256 checksum
How to use checksums
17b8216bed850d4d700f22daa1532b46511a15d64e13da90cec95b71de4a0265
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.0 CPython/3.10.11 Linux/6.1.36

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page