Skip to main content
License License Version Version
Github Actions Github Actions Coverage CodeCov
Supported versions Python Versions Wheel Wheel
Status Status Downloads Downloads

DocCron

Schedule with Docstrings

Installation

pip install DocCron

Description

Cron-based scheduler inspired by doctest

Example

Cron jobs can be embedded into docstrings by using a literal block (::). Literal blocks should start with /etc/crontab.

Standard/Extended Format

Run hello() at every 2nd minute and 3rd minute:

import time


def hello():
    """
    Print "hello world" at every 2nd minute and 3rd minute:

    /etc/crontab::

        */2 * * * *
        */3 * * * *
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S'), "hello world")


if __name__ == '__main__':
    import doccron
    doccron.run_jobs()

Quartz Format

Run hello() at every 2nd second and 3rd second:

import time


def hello():
    """
    Print "hello world" every 2nd second and 3rd second:

    /etc/crontab::

        */2 * * * * *
        */3 * * * * *
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S'), "hello world")


if __name__ == '__main__':
    import doccron
    doccron.run_jobs(quartz=True)

Timezone-Awareness (CRON_TZ)

DocCron now support CRON_TZ. The value of CRON_TZ only applies to succeeding cron jobs. DocCron supports multiple CRON_TZ in a cron table. The default timezone value is the local/system timezone, if not specified.

import time


def hello():
    """
    Print "hello world" at every 2nd minute and 3rd minute:

    /etc/crontab::
    
        CRON_TZ=UTC
        */2 * * * *
        */3 * * * *
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S%z'), "hello world")


if __name__ == '__main__':
    import doccron
    doccron.run_jobs()

Features

TODO

  • Human-readable date/time strings

References

Author

Metadata

Release files for doccron 1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doccron 1.6.2
File Size Uploaded
doccron-1.6.2.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for doccron 1.6.2
File Interpreter ABI Platform
doccron-1.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / doccron-1.6.2.tar.gz

Download URL doccron-1.6.2.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2eab323ce775ba9715b2d5bb8ec64fce69d4f8a747e1cb287c843eb5e6dbac75
BLAKE2b-256 checksum
How to use checksums
7bd091c81c393d3008e03403df73d27a9ac7c6f769b855adbefab3eac2be2a4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure

Release files / doccron-1.6.2-py3-none-any.whl

Download URL doccron-1.6.2-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bc7fa2997f642ae1aa131172c41434fa19fae20e43fc63520245ed1e0f73e8b
BLAKE2b-256 checksum
How to use checksums
5312305dac523c9c7563b7d017f2ffdb55b1c700407ac6b5fca3ff0b8f61e71b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure

Release history Release notifications | RSS feed

This release

1.6.2 This release

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page