CronHook
Home / Guides / Celery / Python
Python Distributed Tasks

Celery Background Job Monitoring

Monitor Celery beat tasks and background workers with Python requests or urllib. Detect worker stalls, memory leaks, and silent worker crashes.

1. Success Ping Setup

Ping when your job completes successfully
Celery / Python — Success Ping
import requests
from celery import shared_task

@shared_task
def sync_user_data():
    try:
        # Your task logic
        perform_sync()
        requests.get("https://cronhook.site/ping/YOUR_CHECK_ID", timeout=5)
    except Exception as exc:
        requests.get("https://cronhook.site/ping/YOUR_CHECK_ID/fail", timeout=5)
        raise exc

2. Failure & Exception Handling

Ping /fail for instant failure dispatch without waiting for timeout
Celery / Python — Failure Catch
# Celery Task Failure Signal Handler
from celery.signals import task_failure
import urllib.request

@task_failure.connect(sender=sync_user_data)
def task_failure_handler(task_id, exception, args, kwargs, traceback, einfo, **kw):
    urllib.request.urlopen("https://cronhook.site/ping/YOUR_CHECK_ID/fail")

How to Implement in Celery / Python

1

Create a Celery task monitor

Configure a monitor in CronHook matching your Celery Beat crontab schedule.

2

Add HTTP ping calls

Use requests or urllib inside your Celery task body to ping CronHook upon successful completion.

3

Handle worker failures with signals

Attach a Celery task_failure signal handler to send failure pings instantly if a worker crashes.

Pro-Tip for Celery / Python Developers

Python Timeout Safeguard: Always pass a short timeout (e.g. timeout=5) to requests.get() so network latency never blocks worker execution.