Enabling flexible and idiomatic regular execution of tasks.
Project description
zsv.ticker enables flexible and idiomatic regular execution of tasks:
from zsv.ticker import Ticker
ticker = Ticker()
ticker.start(5)
while ticker.tick():
execute_task()
Ticker aims to be more idiomatic and easy to use than a time calculation and sleep call, and further enables the instantaneous termination of a waiting task:
import signal
from time import sleep
from zsv.ticker import Ticker
ticker = Ticker()
ticker.start(5)
def abort(signum, frame):
ticker.stop()
signal.signal(signal.SIGINT, abort)
while ticker.tick():
print("tick")
sleep(2)
print("tock")
The above script wraps a stop call in a signal handler registered to SIGINT: hitting Ctrl+C after the script prints “tick” but before it prints “tock” will yield a final “tock” before it terminates.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zsv.ticker-1.1.0.tar.gz.
File metadata
- Download URL: zsv.ticker-1.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7b088bd3e73e3b5d65b4c4ed6a1fa1e712521fdd18c0c705c290264c639b6d7
|
|
| MD5 |
d76cf9c7293112ba08194be736d12e3a
|
|
| BLAKE2b-256 |
0406b84dd0e779f2482c542fed586795a70e3e4b62f6c6d31f27ad24c26c6f24
|
File details
Details for the file zsv.ticker-1.1.0-py3-none-any.whl.
File metadata
- Download URL: zsv.ticker-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65249d3a413e9fa32d84f285326e9711576df215a0691447a7ec5f5b083a0cd2
|
|
| MD5 |
187d032e6d8e4d2318d405aee3d03ec8
|
|
| BLAKE2b-256 |
6b3dd0cb11d4514aab02beed1d109ec14db00f7e13e3f457b693f6ae5c070643
|