Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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`](

## Installation
pip install timeloop

## Writing jobs
import time

from timeloop import Timeloop
from datetime import timedelta

tl = Timeloop()

def sample_job_every_2s():
print "2s job current time : {}".format(time.ctime())

def sample_job_every_5s():
print "5s job current time : {}".format(time.ctime())

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.


while True:
except KeyboardInterrupt:

## 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```

## Author
* **Sankalp Jonna**

Email me with any queries: [](

Project details

Download files

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

Files for timeloop, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size timeloop-1.0.2-py2-none-any.whl (5.2 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size timeloop-1.0.2.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page