Timeloop is a service that can be used to run periodic tasks after a certain interval.

Each job runs on a separate thread and when the service is shut down, it waits till all tasks currently being executed are completed.
Inspired by this blog [`here`](https://www.g-loaded.eu/2016/11/24/how-to-terminate-running-python-threads-using-signals/)
## Installation
```sh
pip install timeloop
```
## Writing jobs
```python
import time
from timeloop import Timeloop
from datetime import timedelta
tl = Timeloop()
@tl.job(interval=timedelta(seconds=2))
def sample_job_every_2s():
print "2s job current time : {}".format(time.ctime())
@tl.job(interval=timedelta(seconds=5))
def sample_job_every_5s():
print "5s job current time : {}".format(time.ctime())
@tl.job(interval=timedelta(seconds=10))
def sample_job_every_10s():
print "10s job current time : {}".format(time.ctime())
```
## Start time loop in separate thread
By default timeloop starts in a separate thread.
Please do not forget to call ```tl.stop``` before exiting the program, Or else the jobs wont shut down gracefully.
```python
tl.start()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
tl.stop()
break
```
## Start time loop in main thread
Doing this will automatically shut down the jobs gracefully when the program is killed, so no need to call ```tl.stop```
```python
tl.start(block=True)
```
## Author
* **Sankalp Jonna**
Email me with any queries: [sankalpjonna@gmail.com](sankalpjonna@gmail.com).
Metadata
Release files for timeloop 1.0.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 |
|---|---|---|---|---|
| timeloop-1.0.2.tar.gz | 2.9 kB | Without provenance | Details for timeloop-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timeloop-1.0.2-py2-none-any.whl | Python 2 | none | any | Details for timeloop-1.0.2-py2-none-any.whl |
Total release size: 8.1 kB
Release files / timeloop-1.0.2.tar.gz
| Download URL | timeloop-1.0.2.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e716c67fe6bcadcee7ddb91e2520792426818a70f27e630cfbbbd9becc48a13
|
|
BLAKE2b-256 checksum How to use checksums |
6a953e39ee32f15a8e9dea46bb52300611a5351964eeaa393bafb0d738e90ce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.12
|
Release files / timeloop-1.0.2-py2-none-any.whl
| Download URL | timeloop-1.0.2-py2-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
70cb69eeef39968ea0e6dd68a3a3a51257d5f4aa27b177ab1b19ca86ff525946
|
|
BLAKE2b-256 checksum How to use checksums |
ade7371d64fc6c6fce53c490fc38816a77fe8c75ff608edc0807170ff3c62bf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.12
|
Security for timeloop 1.0.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.