Skip to main content

Cron job storage, execution, and result tracking built on the Tigrbl engine.

Project description

Tigrbl Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - tigrbl_api_cron


Tigrbl API Cron ⏰

A lightweight Tigrbl application that stores cron schedules, exposes CRUD APIs, and runs registered jobs while capturing their execution results.

✨ Features

  • 🗄️ Persists cron jobs as first-class CronJob rows with default CRUD verbs.
  • 🪪 Tracks validity windows, timestamps, and last execution metadata for each schedule.
  • 📜 Records every execution in the CronJobResult table for full observability.
  • ⚙️ Provides a simple registry and executor to run due jobs and persist their outputs or failures.
  • 🚀 Ships with a ASGI application constructor for rapid deployment.

📦 Installation

Using uv

uv add tigrbl_api_cron

Using pip

pip install tigrbl_api_cron

🚀 Quick Start

import asyncio
from datetime import datetime, timezone

from tigrbl_api_cron import (
    CronJob,
    build_app,
    execute_due_jobs,
    register_cron_job,
)

# 1. Build and initialize the API (SQLite in-memory by default)
app = build_app()
asyncio.run(app.initialize())

# 2. Register a callable that will be invoked when its cron job is due
@register_cron_job("demo.pkg")
async def demo_job(*, job: CronJob, session, scheduled_for, now):
    return {"ran_at": now.isoformat()}

# 3. Create a cron job entry (via ORM, REST, or RPC)
async def seed_job():
    async with app.engine.asession() as session:
        job = CronJob(pkg_uid="demo.pkg", cron_expression="*/5 * * * *")
        session.add(job)
        await session.commit()

asyncio.run(seed_job())

# 4. Run due jobs and capture their results
asyncio.run(execute_due_jobs(app, now=datetime.now(timezone.utc)))

🧪 Executing Jobs

  • Register handlers with register_cron_job(pkg_uid).
  • Call execute_due_jobs(app, now=...) from a scheduler or worker process.
  • Results are written to the CronJobResult table and surfaced via the REST API.

📄 License

This project is licensed under the terms of the Apache 2.0 license.

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

tigrbl_api_cron-0.1.2.dev21.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

tigrbl_api_cron-0.1.2.dev21-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file tigrbl_api_cron-0.1.2.dev21.tar.gz.

File metadata

  • Download URL: tigrbl_api_cron-0.1.2.dev21.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tigrbl_api_cron-0.1.2.dev21.tar.gz
Algorithm Hash digest
SHA256 4a3907d10cbf043fcb9c49e94e3188e5a8a1414b2575acf30e437ec44d5c8b37
MD5 ec9acf615499c7dfe5321f12d7809fe4
BLAKE2b-256 4a9060647c8a167809112669a5f6824c363839394e49876b5268a410748930d9

See more details on using hashes here.

File details

Details for the file tigrbl_api_cron-0.1.2.dev21-py3-none-any.whl.

File metadata

  • Download URL: tigrbl_api_cron-0.1.2.dev21-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tigrbl_api_cron-0.1.2.dev21-py3-none-any.whl
Algorithm Hash digest
SHA256 9b8003da65a74663b4a5cc34f142306802c6940ef61b71953c9e9893d2a0af47
MD5 0972a831308d518cd23ea1456f9b7de8
BLAKE2b-256 a2bf9f06bf204f7870840c7dd072760518062d3892e5bd7e1c0e98d463162bb0

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