Skip to main content

Schedule with Docstrings

Project description

DocCron

Schedule with Docstrings

License License Version Version
Github Actions Github Actions Coverage CodeCov
Supported versions Python Versions Wheel Wheel
Status Status Downloads Downloads

Support

If you like DocCron or if it is useful to you, show your support by buying me a coffee.

Buy Me A Coffee

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.1.tar.gz (10.0 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.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doccron-1.6.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.11.0-1022-azure

File hashes

Hashes for doccron-1.6.1.tar.gz
Algorithm Hash digest
SHA256 59e47206827fdce821595b8de40aace4fa0f3770f10edd26bd6153548ca413c4
MD5 3ddb3d289e379103a0741619b75f0f7d
BLAKE2b-256 cd97d58d078c439cd5a1a1f739c318e7d586f55b3642b71c4f8f745973a9cc93

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doccron-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.11.0-1022-azure

File hashes

Hashes for doccron-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 785d60dfc823f30659ff81626af807c015684e657aca1c2773b8e7b0a629ef42
MD5 1c452cadf41a69be794e5434badb64fe
BLAKE2b-256 b943f8bb7eef4f830d9f59b7f7175c053d0f05eeff673d994621acc638ace915

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