Skip to main content

Schedule with Docstrings

Project description

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

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

doccron-1.6.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

doccron-1.6.2-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file doccron-1.6.2.tar.gz.

File metadata

  • Download URL: doccron-1.6.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure

File hashes

Hashes for doccron-1.6.2.tar.gz
Algorithm Hash digest
SHA256 2eab323ce775ba9715b2d5bb8ec64fce69d4f8a747e1cb287c843eb5e6dbac75
MD5 21fc9af762ff62f25964888cc134abd4
BLAKE2b-256 7bd091c81c393d3008e03403df73d27a9ac7c6f769b855adbefab3eac2be2a4e

See more details on using hashes here.

File details

Details for the file doccron-1.6.2-py3-none-any.whl.

File metadata

  • Download URL: doccron-1.6.2-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure

File hashes

Hashes for doccron-1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc7fa2997f642ae1aa131172c41434fa19fae20e43fc63520245ed1e0f73e8b
MD5 140889ac114b4feaff58e6938d21107c
BLAKE2b-256 5312305dac523c9c7563b7d017f2ffdb55b1c700407ac6b5fca3ff0b8f61e71b

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