Skip to main content

When you have to do something... later.

Project description


A simple python library to schedule work in the future with ability to loop infinitely. Does not depend on any 3rd party libraries.


The package can be simply installed using on of these methods:

  • pip: pip install doitlater
  • poetry: poetry add doitlater
  • poetry: poetry add git+


Simplest example:

from datetime import datetime, timedelta
from doitlater import Later

later = Later()

@later.on(datetime(2021, 1, 1))
def say_hello():
    print("Happy new years in 2021!")

if __name__ == "__main__":

To call the same function every 10 seconds with 30 seconds cold start:

@later.on( + timedelta(seconds=30),
def repeatable_work():
    print("Hello every 10 seconds!")

The later.on() is stackable so this will work too (will be executed every 5 and every 7 days):

@later.on(datetime(2021, 1, 1), timedelta(days=5))
@later.on(datetime(2021, 1, 1), timedelta(weeks=1))
def say_hello():
    print("Happy new years in 2021!")

You can also pass a list of datetime or timedelta (or a mixed one) when to execute the function:

@later.on(datetime(2021, 1, 1), [
    datetime(2021, 2, 1),
    datetime(2021, 3, 1),
    timedelta(days=31)], loop=False)
def say_hello():
    print("Happy new years in 2021!")

If you want to stop executing the same function just return False:

@later.on(datetime(2021, 1, 1), timedelta(seconds=5), loop=True)
def only_one_hello():
    print("This will appear only once!")
    return False

If you have multiple functions and one of them throws an exception but you don't want to stop the work, pass ignore_errors=True to Later() object:

later = Later(ignore_errors=True)

By default, library will output logs on errors. To change logging, use dictConfig:

from datetime import datetime, timedelta
from doitlater import Later
from logging.config import dictConfig

        "version": 1,
        "formatters": {
            "default": {
                "format": "[%(asctime)s] %(levelname)s in %(module)s: %(message)s",
        "handlers": {
            "default": {"class": "logging.StreamHandler", "formatter": "default",}
        "root": {"level": "INFO", "handlers": ["default"]},

later = Later()

@later.on(datetime(2021, 1, 1))
def say_hello():
    print("Happy new years in 2021!")

if __name__ == "__main__":


Later(workers, ignore_errors) takes these parameters:

  • workers - number of threads to use, defaults to maximum number of threads supported by CPU.
  • ignore_errors - False will exit when one of the function throws an error, True - ignores exceptions and will resume the work.

later.on(exactly, repeat, loop) function takes these parameters:

  • exactly - on which time perform the first function call.
  • repeat - a single value or a list of datetime, timedelta or both on when to repeat the call. If None is passed the function will not be called again. Defaults to None.
  • loop - whether repeat calling times from repeat. Defaults to True. does not take any parameters.

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 doitlater, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size DoItLater-0.1.2-py3-none-any.whl (5.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size DoItLater-0.1.2.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page