- Version:
- 0.1.0
Introduction
The timer3 module lets you schedule Python functions at specific times, or at an interval. It can be used as a replacement to threading.Timer, the difference is that timer3 is always only using a single thread (unless you manually start more of them)
You should never use this to apply expensive operations, as this would not be effective when running in a single thread, rather you should make the timer move the operations to a execution pool (like a thread/multiprocessing pool, or maybe sending a message):
>>> pool = multiprocessing.Pool() >>> timer3.apply_after(10000, pool.apply_async, (expensive_fun, ))
Installation
You can install timer3 either via the Python Package Index (PyPI) or from source.
To install using pip,:
$ pip install timer3
Examples
Apply function after n msecs:
>>> import timer3 >>> timer3.apply_after(msecs, fun, args, kwargs, priority=0)
Apply function every n msecs:
>>> timer3.apply_interval(msecs, fun, args, kwargs, priority=0)
Apply function at a specific date (a datetime object):
>>> timer3.apply_at(datetime, fun, args, kwargs, priority=0)
Cancelling timers
The apply_* functions returns a timer3.Entry instance, you can use this to cancel the execution:
>>> tref = timer3.apply_after(msecs, fun, args, kwargs) >>> tref.cancel()
Running custom Timer threads
When using the module interface a default timer thread is started as soon as you schedule something. If you want to keep track of the thread manually, you can use the timer3.Timer class:
>>> timer = timer3.Timer() >>> timer.apply_after(msecs, fun, args, kwargs) >>> timer.stop() # stops the thread and joins it.
License
This software is licensed under the New BSD License. See the LICENSE file in the top distribution directory for the full license text.
Metadata
Release files for timer3 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| timer3-0.1.2.tar.gz | 5.1 kB | Without provenance | Details for timer3-0.1.2.tar.gz |
Release files / timer3-0.1.2.tar.gz
| Download URL | timer3-0.1.2.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0e69921d6ab46adbe6fcfd54c435e746b9da01bbb9999a233c8c31761330f95
|
|
BLAKE2b-256 checksum How to use checksums |
375a05977765f1f0943a05865121e7fb79e93c98259245d89a5aa81fbab29039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Security for timer3 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.