Skip to main content

Celery + Redis task queue with admin UI for monitoring and retrying failed/stuck tasks

Project description

simple_module_background_tasks

Celery + Redis background-task module for simple_module apps. Provides a pre-configured Celery instance, a task registration hook, and an admin UI for monitoring + retrying failed/stuck tasks.

Install

pip install simple_module_background_tasks

Requires a Redis broker — set SM_CELERY_BROKER_URL (default redis://localhost:6379/0).

What it provides

  • register_background_tasks() module hook — modules declare tasks here; the registry wires them into the Celery app at boot.
  • Admin UI at /background-tasks/admin — list recent runs, retry failed, inspect tracebacks.
  • Shared Celery app accessible via from background_tasks import celery_app (import name background_tasks, distribution name simple_module_background_tasks).

Usage

Declare a task in a module:

# modules/reports/reports/tasks.py
from background_tasks import celery_app   # type: ignore[import-not-found]


@celery_app.task(name="reports.generate")
def generate_report(report_id: int) -> None:
    ...

Register it:

class ReportsModule(ModuleBase):
    meta = ModuleMeta(name="reports", depends_on=["background_tasks"])

    def register_background_tasks(self):
        from . import tasks  # noqa: F401 — side-effect: registers tasks

Enqueue from an endpoint:

generate_report.delay(report_id=42)

Run a worker locally:

uv run celery -A background_tasks.celery_app worker --loglevel=info

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting
  • celery[redis]>=5.4, redis>=5

License

MIT — see 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

simple_module_background_tasks-0.0.9.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file simple_module_background_tasks-0.0.9.tar.gz.

File metadata

File hashes

Hashes for simple_module_background_tasks-0.0.9.tar.gz
Algorithm Hash digest
SHA256 40225065641b15eec914c9c92884bd032d2e3b8f7e4744ecf9a3cbed4cb8707d
MD5 adfdfb80d8014f31cb35a0acc6b40019
BLAKE2b-256 4520e564735358d283f18f24b0cab366fb36de45767f11283f3d42a9a455cf5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_background_tasks-0.0.9.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_background_tasks-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_background_tasks-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 87155c546f3fd0ada0d09595476ce1143f59458a122880b02153f7dfb3fdd250
MD5 3d06a6886c62c53558ff828b3782c20e
BLAKE2b-256 97b744f6c2ddc0ac0d152ac19fa235bd45cd926f75634501d48a884136e2ffe2

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_background_tasks-0.0.9-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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