skip to navigation
skip to content

Not Logged In

glock 0.1

Abstraction of time to ease testing

# 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.

 
File Type Py Version Uploaded on Size
glock-0.1.tar.gz (md5) Source 2012-12-18 3KB
  • Downloads (All Versions):
  • 1 downloads in the last day
  • 31 downloads in the last week
  • 179 downloads in the last month