resettabletimer
Wrapper for threading.Timer
to provide a resettable Timer implementation. Also provides fake timer for testing.
Usage
ResettableTimer
from resettabletimer import ResettableTimer
delay = 5
function = print
t = ResettableTimer(delay, function, ["Hello"], {"end":" timer!\n"})
t.start()
t.reset()
FakeTimer
from resettabletimer import FakeTimer
t = FakeTimer(2, print, ["Hello"], {"end":" timer!\n"})
t.start()
t.pass_time(2)
Testing
Check and automatically fix formatting with:
pycodestyle resettabletimer
autopep8 -aaar --in-place resettabletimer
Run static analysis with:
pylint -E --enable=invalid-name,unused-import,useless-object-inheritance resettabletimer
Run unit tests:
python3 -m unittest discover -s tst/
coverage run \
--branch \
--source resettabletimer/ \
-m unittest discover -s tst/
coverage report -m