Socket
Socket
Sign inDemoInstall

python-cron

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    python-cron

A simple Python library providing cron functionality via the use of a single decorator.


Maintainers
1

Readme

banner

A simple Python library providing cron functionality via the use of a single decorator.

Installation

The latest version of pycron may be installed via pip as follows:

pip install python-cron

Usage

The pycron module provides a @cron decorator that may be used to mark functions declared async as cron jobs. The decorator takes a croniter-style cron string as input to determine when the function should be executed. For example, the following test function would be automatically executed every 5 seconds:

from datetime import datetime
import pycron

@pycron.cron("* * * * * */5")
async def test(timestamp: datetime):
    print(f"test cron job running at {timestamp}")

if __name__ == '__main__':
    pycron.start()

All functions declared with the @cron decorator should take a single positional argument that will contain the current timestamp when the function is automatically invoked. Also note the usage of the pycron.start() method. This function signals that automated job scheduling and execution should begin and it should be invoked after all jobs have been declared.

For more information on the format of the cron strings that should be provided to the @cron decorator, please see the croniter documentation on PyPI.

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc