Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Wrapper for threading.Timer to allow resetting

Project description

resettabletimer

Build Status

Wrapper for threading.Timer to provide a resettable Timer implementation. Also provides fake timer for testing.

Usage

ResettableTimer

from ResettableTimer import ResettableTimer

delay = 5 # seconds
function = print

# Create resettable timer
t = ResettableTimer(delay, function, ["Hello"], {"end":" timer!\n"})

# Starting and canceling work similarly than with threading.Timer
t.start()

# Wait 1-5 seconds

# Reset the timer
t.reset()

# Hello should be printed after five seconds

FakeTimer

from FakeTimer import FakeTimer

t = FakeTimer(2, print, ["Hello"], {"end":" timer!\n"})

# Starting and canceling work similarly than with threading.Timer
t.start()

# Wait >2 seconds
# Nothing happens

# Time passage is controlled with pass_time
t.pass_time(2)

# Hello should be printed

Testing

Run unit tests with command:

cd resettabletimer

python3 -m unittest discover -s tst/

Get test coverage with commands:

cd resettabletimer

coverage run -m unittest discover -s tst/
coverage report -m

Project details


Release history Release notifications

This version
History Node

0.6.2

History Node

0.6.1

History Node

0.6.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
resettabletimer-0.6.2.tar.gz (2.0 kB) Copy SHA256 hash SHA256 Source None Jun 19, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page