Skip to main content

🔮 Crono

Crono is a programmatic time-based job scheduler that gives your application a sense of timing.

import crono
crono.request('POST', 'https://your.app/').after(hours=42)

Read more

Install

Install package:

pip install crono

Run the servers:

redis-server &
celery worker --app=crono.queue:queue --hostname=worker1@%h
celery beat --app=crono.queue:queue

Usage

Triggers

A trigger defines when a job will be executed. There are 4 types of triggers: after, on, every, and cron.

after

after specifies a countdown until the execution of a task. It will only occur once. It takes at least 1 keyword argument: hours, minutes, and/or seconds, of type

crono.after(minutes=30).…

on

on specifies the execution of a task at a specific date and time. It will only occur once. It takes 1 positional argument of type <datetime.datetime>.

import datetime
date = datetime.datetime(2019, 7, 4)
crono.on(date).…

every

every specifies a frequency at which to execute a task. It will occur multiple times. It takes at least 1 keyword argument: hours, minutes, and/or seconds, of type

crono.every(hours=1, minutes=30).…

cron

cron uses an expression to specify the execution time. It will occur mutiple times. It takes exactly 1 positional argument of type <str>.

crono.cron('0 6 * * 2').…

Tasks

A task defines what a job will do. There are 4 types of tasks: log, request, message, and email.

log

log uses the standard logging Python library.

crono.log('DEBUG', '{text}', *args, **kwargs)

request

request sends an HTTP request. It is powered by the Requests library.

crono.request('POST', '{url}', **kwargs).…

message

message sends an SMS. It is powered by Twilio. To use it, you will have to specify twilio_account_sid and twilio_auth_id.

Not implemented, yet.

email

email sends an email. It is powered by Postmark. To use it, you will have to specify postmark_api_key and postmark_sender.

Not implemented, yet.

Examples

import crono

# Timer
crono.request('POST', '{url}').after(minutes=1)

# Datetime
crono.log('DEBUG', '{text}').on(<datetime>)

# Interval
crono.email(…).every(hours=1) # `email` task not implemented (yet)

# Cron
crono.message(…).cron('0 6 * * 2') # `message` task not implemented (yet)

Configuration

Crono comes with sensible default values that you can override:

# Required
CELERY_BROKER

# Optional
CELERY_RESULT_BACKEND
REDIS_MAX_CONNECTIONS (default: 20)	
CELERY_BROKER_POOL_LIMIT (default: 0)
CELERY_TASK_IGNORE_RESULT (default: True)
CELERY_BEAT_MAX_LOOP_INTERVAL (default: 300)
CELERY_WORKER_MAX_TASKS_PER_CHILD (default: 100)

Test

python -m pytest

Development

Packaging

# Generating distribution archives
$ python setup.py sdist bdist_wheel

# Uploading the distribution archives
$ twine upload --skip-existing dist/*

Metadata

Release files for crono 0.1.8

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

Source distribution (sdist)

Source distribution for crono 0.1.8
File Size Uploaded Provenance
crono-0.1.8.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 12.0 kB

Release files / crono-0.1.8.tar.gz

Download URL crono-0.1.8.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0ab937cab9713a98f84f62385d206ce9cbba28af1ef84fb4a130d099ede4949d
BLAKE2b-256 checksum
How to use checksums
9ebcaf0cb5b7279aeaa2ccc8f9d9fb53e4791ebf0e7b0f494dc83e9c37d5f7fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.7.3

Release files / crono-0.1.8-py3-none-any.whl

Download URL crono-0.1.8-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
482950b8cf4d41bddc1a37dbe2d80e9bcc9e4102da67bd8b1ac7550962ef7e26
BLAKE2b-256 checksum
How to use checksums
3e5ac697e0c7e2be8fbdff220b813648430a7d6b5818cfb04f4c6a6952babde0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.7.3

Security for crono 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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