Skip to main content

Cron job monitoring and heartbeat monitoring SDK for Python. Monitor scheduled tasks, background jobs, and cron jobs with simple ping telemetry. Get alerts when cron jobs fail, miss their schedule, or run too long.

Project description

CronBeats Python SDK (Ping)

PyPI version Downloads Python versions

Official Python SDK for CronBeats ping telemetry.

Install

pip install cronbeats-python

Quick Usage

from cronbeats_python import PingClient

client = PingClient("abc123de")
client.start()
# ...your work...
client.success()

Real-World Cron Job Example

from cronbeats_python import PingClient

client = PingClient("abc123de")
client.start()

try:
    # your actual cron work
    process_emails()
    client.success()
except Exception:
    client.fail()

Progress Tracking

Track your job's progress in real-time. CronBeats supports two distinct modes:

Mode 1: With Percentage (0-100)

Shows a progress bar and your status message on the dashboard.

Use when: You can calculate meaningful progress (e.g., processed 750 of 1000 records)

# Percentage mode: 0-100 with message
client.progress(50, "Processing batch 500/1000")

# Or using dict
client.progress({
    "seq": 75,
    "message": "Almost done - 750/1000",
})

Mode 2: Message Only

Shows only your status message (no percentage bar) on the dashboard.

Use when: Progress isn't measurable or you only want to send status updates

# Message-only mode: None seq, just status updates
client.progress(None, "Connecting to database...")
client.progress(None, "Starting data sync...")

What you see on the dashboard

  • Mode 1: Progress bar (0-100%) + your message → "75% - Processing batch 750/1000"
  • Mode 2: Only your status message → "Connecting to database..."

Complete Example

from cronbeats_python import PingClient

client = PingClient("abc123de")
client.start()

try:
    # Message-only updates for non-measurable steps
    client.progress(None, "Connecting to database...")
    db = connect_to_database()
    
    client.progress(None, "Fetching records...")
    total = db.count()
    
    # Percentage updates for measurable progress
    for i in range(total):
        process_record(i)
        
        if i % 100 == 0:
            percent = int((i * 100) / total)
            client.progress(percent, f"Processed {i} / {total} records")
    
    client.progress(100, "All records processed")
    client.success()
    
except Exception:
    client.fail()
    raise

Notes

  • SDK uses POST for telemetry requests.
  • job_key must be exactly 8 Base62 characters.
  • Retries happen only for network errors, HTTP 429, and HTTP 5xx.
  • Default 5s timeout ensures the SDK never blocks your cron job if CronBeats is unreachable.

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

cronbeats_python-0.1.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

cronbeats_python-0.1.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file cronbeats_python-0.1.3.tar.gz.

File metadata

  • Download URL: cronbeats_python-0.1.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for cronbeats_python-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7f64d500e59baf8f4e023a9b3de3d6084c9151745acf6aecf53290ea7cb1a45f
MD5 ae736d32e63d5ad0c27a6c47f17cdf2e
BLAKE2b-256 fe72185074db1087d63754864e2f9b7fa4cc656e07fef3c3840d4caa68b669fe

See more details on using hashes here.

File details

Details for the file cronbeats_python-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cronbeats_python-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e74235514fdcadcfb29484149986a3aa8001ecf707adc7af03ffda25ca127fea
MD5 d910777eeb1707e12205e202f043a7f4
BLAKE2b-256 b902804cd444dd0d8b6edd80780ace6cd5a43e51e31482374de418ef0ee3e113

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