Skip to main content

A simple in-process python scheduler library with asyncio, threading and timezone support.

Project description

scheduler

A simple in-process python scheduler library with asyncio, threading and timezone support. Schedule tasks by their time cycles, fixed times, weekdays, dates, weights, offsets and execution counts and automate Jobs.

repository mirror license pipeline status coverage report Code style: black Imports: isort

pkgversion versionsupport Downloads Week Downloads Total


If you find the scheduler library beneficial, please consider supporting the project by starring it on GitHub.

GitHub Repo stars

Features

Installation

pip

scheduler can be installed directly from the PyPI repositories with:

pip install scheduler

Alternatively install scheduler from the git repository with:

git clone https://gitlab.com/DigonIO/scheduler.git
cd scheduler
pip install .

Example: How to schedule Jobs

The following example shows how the Scheduler is instantiated and how basic Jobs are created. For advanced scheduling examples please visit the online documentation.

import datetime as dt

from scheduler import Scheduler
from scheduler.trigger import Monday, Tuesday


def foo():
    print("foo")


schedule = Scheduler()

schedule.cyclic(dt.timedelta(minutes=10), foo)

schedule.minutely(dt.time(second=15), foo)
schedule.hourly(dt.time(minute=30, second=15), foo)
schedule.daily(dt.time(hour=16, minute=30), foo)
schedule.weekly(Monday(), foo)
schedule.weekly(Monday(dt.time(hour=16, minute=30)), foo)

schedule.once(dt.timedelta(minutes=10), foo)
schedule.once(Tuesday(), foo)
schedule.once(dt.datetime(year=2022, month=2, day=15, minute=45), foo)

A human readable overview of the scheduled jobs can be created with a simple print statement:

print(schedule)
max_exec=inf, tzinfo=None, priority_function=linear_priority_function, #jobs=9

type     function / alias due at                 due in      attempts weight
-------- ---------------- ------------------- --------- ------------- ------
MINUTELY foo()            2021-05-26 03:55:15   0:00:14         0/inf      1
CYCLIC   foo()            2021-05-26 04:05:00   0:09:59         0/inf      1
ONCE     foo()            2021-05-26 04:05:00   0:09:59           0/1      1
HOURLY   foo()            2021-05-26 04:30:15   0:35:14         0/inf      1
DAILY    foo()            2021-05-26 16:30:00  12:34:59         0/inf      1
WEEKLY   foo()            2021-05-31 00:00:00    4 days         0/inf      1
WEEKLY   foo()            2021-05-31 16:30:00    5 days         0/inf      1
ONCE     foo()            2021-06-01 00:00:00    5 days           0/1      1
ONCE     foo()            2022-02-15 00:45:00  264 days           0/1      1

Executing pending Jobs periodically can be achieved with a simple loop:

import time

while True:
    schedule.exec_jobs()
    time.sleep(1)

Resources

Sponsor

Digon.IO GmbH Logo

Digon.IO provides dev & data end-to-end consulting for SMEs and software companies. (Website) (Technical Blog)

The sponsor logo is the property of Digon.IO GmbH. Standard trademark and copyright restrictions apply to any use outside this repository.

License

  • Library source code: Licensed under LGPLv3.

Project details


Download files

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

Source Distribution

scheduler-0.8.11.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scheduler-0.8.11-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file scheduler-0.8.11.tar.gz.

File metadata

  • Download URL: scheduler-0.8.11.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for scheduler-0.8.11.tar.gz
Algorithm Hash digest
SHA256 b2234a069448a617abbc511b9e18f48c4deb3dcd9dcc51721d9c90ef2943b72a
MD5 c775adcce5acd8b8db3c14a04915fec7
BLAKE2b-256 73f256aaad8051752a321de1d8a04c80345e21f2c6e573fb9a1fb71f11141a41

See more details on using hashes here.

File details

Details for the file scheduler-0.8.11-py3-none-any.whl.

File metadata

  • Download URL: scheduler-0.8.11-py3-none-any.whl
  • Upload date:
  • Size: 34.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for scheduler-0.8.11-py3-none-any.whl
Algorithm Hash digest
SHA256 db55040e0f1c0824a9b02ff37fcecdcd10c2ee1d5b86d1761648981a555a00f8
MD5 da969e28de36e304a06bf609dbe5ff3e
BLAKE2b-256 bef93e2e4944104b47e6b075fdc9cb890758ead01fb0d203d8508ecb9cc76680

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page