Skip to main content

Running functions on a schedule for Sanic

Project description

# Sanic Scheduler

Sanic Scheduler runs a functions on a schedule.

## Installation

Automatic installation:
$ pip install sanic-scheduler

Sanic Scheduler is listed in [PyPI]( and can be installed with pip or easy_install.

Manual installation:
$ git clone
$ cd sanic_scheduler
$ python install

Sanic Scheduler source code is [hosted on GitHub](

## Usage

import asyncio
from datetime import datetime, time, timedelta

from sanic import Sanic

from sanic_scheduler import SanicScheduler, task

app = Sanic()
scheduler = SanicScheduler(app)

def hello(app):
"""Runs the function every 30 seconds."""
print("Hello, {0}".format(app),

@task(timedelta(hours=1), time(hour=1, minute=30))
async def foo_bar(_):
"""Runs the function every 1 hours after 1:30."""
await asyncio.sleep(1)

@task(timedelta(minutes=2), timedelta(seconds=10))
def baz(_):
"""Runs the function every 2 minutes after 10 seconds."""

def another(_):
"""Run the function after 10 seconds once."""

if __name__ == "__main__":'', port=5000, debug=True)

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 sanic-scheduler, version 1.0.7
Filename, size File type Python version Upload date Hashes
Filename, size sanic_scheduler-1.0.7-py3-none-any.whl (3.4 kB) File type Wheel Python version 3.6 Upload date Hashes View hashes
Filename, size sanic-scheduler-1.0.7.tar.gz (3.4 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