Skip to main content

A simple in-process python scheduler library with asyncio, threading and timezone support. Use datetime standard library objects for planning of Jobs depending on time cycles, fixed times, weekdays, dates, weights, offsets and execution counts.

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 Documentation

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 .

Arch Linux

The PKGBUILD file can be utilized from the Arch Build System. Download the PKGBUILD file and from within the containing folder run

makepkg -i

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)

Documentation

View the API documentation online.

Sponsor



We would like to thank Digon.IO for sponsoring the development of this library. Digon.IO is building bridges between data science and software development. They enable companies to automate and accelerate their data-driven processes. Please visit their website: digon.io

License

This free and open source software (FOSS) is published under the LGPLv3 license.

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.3.tar.gz (28.2 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.3-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scheduler-0.8.3.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for scheduler-0.8.3.tar.gz
Algorithm Hash digest
SHA256 b2c490a6b5e4bfe452d9a993ecbb259f3638520a2d8e5f44ea2ccf14b8c75a56
MD5 eb79b0d6ba907b88265cb82fa453150e
BLAKE2b-256 7a94ed990215f5d8471ea20add904e1df5d4fe620bd5d4c52b18ac90ef220853

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scheduler-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for scheduler-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 18dc39208d4d02f300d70f2a4f09ce7cab68fd3fc1c51c34f1c4bf5bd0bff94d
MD5 68dbaf919a8ad57049bd83363e6ed152
BLAKE2b-256 7221bf885bfa1fa7667dd7cdab4e599a1cda7a768ddd2823d61037bb593e88bc

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