Skip to main content

Wrapper for threading.Timer to allow resetting

Project description


CI Release

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



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

# Wait 1-5 seconds

# Reset the timer

# Hello should be printed after five seconds


from resettabletimer import FakeTimer

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

# Starting and canceling work similarly than with threading.Timer

# Wait >2 seconds
# Nothing happens

# Time passage is controlled with pass_time

# Hello should be printed


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:

# Run unit tests
python3 -m unittest discover -s tst/

# Run unit tests with coverage analysis
coverage run \
    --branch \
    --source resettabletimer/ \
    -m unittest discover -s tst/
coverage report -m

Project details

Download files

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

Source Distribution

resettabletimer-1.0.0.tar.gz (3.0 kB view hashes)

Uploaded source

Built Distribution

resettabletimer-1.0.0-py3-none-any.whl (4.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page