Skip to main content

Lightweight background task scheduler — no Celery needed

Project description

cronify

Lightweight background task scheduler for Python — no Celery needed


Install

pip install cronify

Usage

from cronify import Scheduler

scheduler = Scheduler()

@scheduler.every(minutes=5)
async def cleanup_expired_tokens():
    await db.execute("DELETE FROM tokens WHERE expires_at < now()")

@scheduler.every(hours=1, run_immediately=True)
async def sync_exchange_rates():
    rates = await fetch_rates()
    await cache.set("rates", rates)

# Start in your FastAPI app:
@app.on_event("startup")
async def startup():
    await scheduler.start()

Features

  • @scheduler.every(seconds=30) — decorator syntax
  • Async and sync functions supported
  • Error resilient — one failing job doesn't stop others
  • No Redis, no Celery, no external broker
  • Pure asyncio — works everywhere Python runs
  • run_immediately=True for instant first execution
  • Zero dependencies

API

scheduler.every(seconds=30)            # every 30 seconds
scheduler.every(minutes=5)             # every 5 minutes
scheduler.every(hours=1)               # every hour
scheduler.every(hours=1, minutes=30)   # every 1.5 hours
scheduler.every(seconds=10, run_immediately=True)  # run now, then every 10s

await scheduler.start()   # start all jobs
await scheduler.stop()    # cancel all jobs
scheduler.jobs             # list registered jobs

License

MIT

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

cronify_scheduler-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

cronify_scheduler-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file cronify_scheduler-0.1.0.tar.gz.

File metadata

  • Download URL: cronify_scheduler-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for cronify_scheduler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb2ef33fe4f84439927d59aa03d24fbf49542c656ffcaaecd029996f1fd792b9
MD5 f67ae5bba30125f8902f7be8da866172
BLAKE2b-256 3634f662765fbfd2bf98f9760228c785c22e47b038583cdc609c567c21dd9728

See more details on using hashes here.

File details

Details for the file cronify_scheduler-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cronify_scheduler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5527737b237b1c6756a3625136bd207a157c79ceeef6dbb0c35999963a34840d
MD5 4047353cbe94b7f9a968383c62db0998
BLAKE2b-256 d4c1dd5d78b68e81f4cbaab344e66922a80072dcd07d8214c2cb3b6cf6e036bd

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