An elegant way to run period tasks.
Project description
# Timeloop
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 a job looks like this
```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())
tl.start()
```
## Author
* **Sankalp Jonna**
Email me with any queries: [sankalpjonna@gmail.com](sankalpjonna@gmail.com).
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 a job looks like this
```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())
tl.start()
```
## Author
* **Sankalp Jonna**
Email me with any queries: [sankalpjonna@gmail.com](sankalpjonna@gmail.com).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timeloop-1.0.tar.gz
(2.6 kB
view hashes)
Built Distribution
timeloop-1.0-py2-none-any.whl
(4.8 kB
view hashes)