Abstraction of time to ease testing
Project description
# Glock - a Clock abstraction for gevent #
Most likely your application is in some way working with the concept of time. It can be timeouts, it can be tasks that should be executed within regular intervals.
Glock (Gevent cLOCK) tries to encapsulate time-related functionality into a simple Clock class. Also provided is a mock Clock class allowing deterministic testing.
Usage:
from glock.clock import Clock
c = Clock() c.call_later(1, fn)
API:
The call_later(seconds, fn, *args, **kw) method calls fn seconds from now. A DelayedCall instance is returned that can be used to reschedule the call (using reset) or cancel it (using cancel).
The clock also have a sleep method that acts just like gevent.sleep. To read out the current time, use the time method.
The MockClock method also has an advance method that is used to advance time in a controlled manner.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file glock-0.1.tar.gz
.
File metadata
- Download URL: glock-0.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b541a9d4229dcbe9ce5a7fec4e3a0ee032fc4ebda4bfdbe9c9c53c9f07dd649e |
|
MD5 | 1f91362ad4eb23f265ecc2466293b12a |
|
BLAKE2b-256 | 519d280890d0fa0dd39310f5753bce4245e60489bad8591c7c158329d1329d87 |