A simple in-process python scheduler library, designed to be integrated seamlessly with the `datetime` standard library.

Overview

scheduler

repository license pipeline status coverage report Documentation Status Code style: black


A simple in-process python scheduler library, designed to be integrated seamlessly with the datetime standard library. Due to the support of datetime objects, scheduler is able to work with time zones. This implementation enables the planning of Job s depending on time cycles, fixed times, weekdays, dates, weights, offsets and execution counts.


Features

  • Easy and user friendly in-process Job scheduling
    • Create recurring Jobs by given date, time, weekday, ...
    • Create recurring Jobs with a given timedelta
    • Oneshot Jobs
  • Job prioritization with linear weighting
  • datetime compatibility
  • Timezone compatibility
  • Lightweight
  • Limit and track the Job execution count
  • High test coverage
  • Online documentation

Installation

scheduler can be installed using pip with the following command:

pip install git+https://gitlab.com/DigonIO/scheduler.git

Alternatively clone the repository and install with:

git clone REPLACE_ME
cd scheduler
pip install .

Example: How to schedule Jobs

Some basics are presented here. For advanced scheduling examples please visit the online documentation. The following example shows how the Scheduler is instantiated and how cyclic Jobs are created:

import time
import datetime as dt
from scheduler import Scheduler, Weekday

def foo(msg = "bar"):
    print(msg)

sch = Scheduler()

sch.schedule(foo, dt.timedelta(minutes=10))  # every 10 minutes
sch.schedule(foo, dt.time(hour=16, minute=45))  # every day at 16:45
sch.schedule(foo, Weekday.MONDAY)  # every monday at 00:00

# every monday at 16:45
sch.schedule(
    foo,
    (Weekday.MONDAY, dt.time(hour=16, minute=45)),
)

# every friday at 00:00, every 10 minutes and every monday at 16:45
sch.schedule(
    foo,
    [
        Weekday.FRIDAY,
        dt.timedelta(minutes=10),
        (Weekday.MONDAY, dt.time(hour=16, minute=45)),
    ],
)

Besides cyclic Jobs, oneshot Jobs can also be easily created:

sch.once(foo, dt.datetime(year=2021, month=2, day=11))  # at given datetime
sch.once(foo, dt.timedelta(minutes=10))  # in 10 minutes

Pass parameters to the function handle foo:

sch.once(foo, dt.timedelta(seconds=10000), params={"msg": "fizz"})
sch.schedule(foo, dt.timedelta(minutes=1), params={"msg": "buzz"})

Create a loop in the host program to execute pending Jobs:

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

Build the documentation

The API documentation can either be viewed online or be generated using Sphinx with numpydoc formatting. To build, run:

sphinx-build -b html doc/ doc/_build/html

Testing

Testing is done using pytest. Using pytest-cov and coverage a report for the tests can be generated with:

pytest --cov=scheduler/ tests/
coverage html

To test the examples in the documentation run:

pytest --doctest-modules doc/examples.rst

TODO

  • Features
    • Support of monthly recurring Jobs (e.g. every second Monday in June and October)
    • Add __repr__ methods to Job and Scheduler
    • Execute all scheduled Jobs
    • Delete all scheduled Jobs
    • Optional Job flag: Discard missed executions befor the last pending execution
    • Execute a Job until a certain datetime stamp
    • Thread safety and background tasks
  • Documentation

License

This software is published under the GPLv3 license.

Owner
Developer Community, Development on GitLab
TimeTagger is a web-based time-tracking solution that can be run locally or on a server

TimeTagger is a web-based time-tracking solution that can be run locally or on a server. In the latter case, you'll want to add authentication, and also be aware of the license restrictions.

Almar Klein 626 Jan 06, 2023
đź•ź Date and time processing language

Date Time Expression dte is a WIP date-time processing language with focus on broad interpretation. If you don't think it's intuitive, it's most likel

Marcelo 303 Dec 19, 2022
A Python module that tries to figure out what your local timezone is

tzlocal This Python module returns a tzinfo object with the local timezone information under Unix and Windows. It requires either Python 3.9+ or the b

Lennart Regebro 159 Dec 16, 2022
Jalali (Shamsi) date and datetime (based on python datetime's module)

PersianTools Jalali (Shamsi) date and datetime (based on python datetime's module) Convert Jalali to Gregorian date/datetime and vice versa Support co

Majid Hajiloo 66 Dec 18, 2022
Cross Platform Application for Calculating Render Time

mdsanima-rt-go Cross Platform Application for Calculating Render Time. Testing This is a base application build on Windows Android and Linux. All buil

MDSANIMA DEV 2 Mar 29, 2022
Delorean: Time Travel Made Easy

Delorean: Time Travel Made Easy Delorean is a library for clearing up the inconvenient truths that arise dealing with datetimes in Python. Understandi

Mahdi Yusuf 1.8k Dec 20, 2022
The Terasic DECA board as a mandelbrot acceleerator

deca-mandelbrot The Terasic DECA board as a mandelbrot accelerator. This is a hobby project to explore parallel computation/pipelining on a FPGA. curr

Hans Baier 11 Aug 29, 2022
A datetime parser in Python by Ari24-cb24 and NekoFantic

datetimeparser A datetime parser in Python by Ari24-cb24 and NekoFantic V 1.0 Erinnerung fĂĽr den Parser Auf falsche Eingaben ĂĽberprĂĽfen Liste an Event

AriDevelopment 13 Dec 30, 2022
ISO 8601 date/time parser

ISO 8601 date/time parser This module implements ISO 8601 date, time and duration parsing. The implementation follows ISO8601:2004 standard, and imple

118 Dec 20, 2022
Datetimes for Humans™

Maya: Datetimes for Humans™ Datetimes are very frustrating to work with in Python, especially when dealing with different locales on different systems

Timo Furrer 3.4k Dec 28, 2022
A Python library for dealing with dates

moment A Python library for dealing with dates/times. Inspired by Moment.js and Kenneth Reitz's Requests library. Ideas were also taken from the Times

Zach Williams 709 Dec 09, 2022
UNIX time from NTP or short UtfN is a simple CLI tool to set the time from an NTP-Server.

UNIX ⌚ from NTP UNIX time from NTP or short UtfN is a simple CLI tool to set the time from an NTP-Server. Sets time and date using the date command pr

Alexander 1 Jan 02, 2022
An python based Timer and Digital Clock

Python-based-Timer- An python based Timer and Digital Clock How to contribute to this repo âť“ Step 1: Fork the this repository Step 2: Clone your fork

Bauddhik-Geeks 3 Sep 16, 2022
Friendly Python Dates

When.py: Friendly Dates and Times Production: Development: User-friendly functions to help perform common date and time actions. Usage To get the syst

Andy Dirnberger 191 Oct 14, 2022
PyTime is an easy-use Python module which aims to operate date/time/datetime by string.

PyTime PyTime is an easy-use Python module which aims to operate date/time/datetime by string. PyTime allows you using nonregular datetime string to g

Sinux 148 Dec 09, 2022
Better dates & times for Python

Arrow: Better dates & times for Python Arrow is a Python library that offers a sensible and human-friendly approach to creating, manipulating, formatt

Arrow 8.2k Jan 05, 2023
python parser for human readable dates

Python parser for human readable dates Key Features • How To Use • Installation • Common use cases • You may also like... • License Key Features Suppo

Scrapinghub 2.2k Jan 08, 2023
Useful extensions to the standard Python datetime features

dateutil - powerful extensions to datetime The dateutil module provides powerful extensions to the standard datetime module, available in Python. Inst

2k Dec 29, 2022
Make Python datetime formatting human readable

Make Python datetime formatting human readable

James Timmins 0 Oct 03, 2021
A simple digital clock made with the help of python

Digital-Clock ⏰ Description 📚 ✔️ A simple digital clock made with the help of python. The code is easy to understand and implement. With this reposit

Mohit 0 Dec 10, 2021