A Django helper to monitor jobs running Celery tasks
- Utilities to track progress of Celery tasks via in-database jobs
- Python >= 3.5
- Django >= 1.8
- Celery >= 4.0.2
- echoices >= 2.5.0
- autoslugged >= 2.0.0
- Run
pip install django-celery-growthmonitor
- Make sure
pandoc
is installed - Run
./pypi_packager.sh
- Run
pip install dist/django_celery_growthmonitor-x.y.z-[...].wheel
, wherex.y.z
must be replaced by the actual version number and[...]
depends on your packaging configuration
('state', echoices.fields.make_echoicefield(default=celery_growthmonitor.models.AJob.EState.CREATED, echoices=celery_growthmonitor.models.AJob.EState, editable=False)),
('status', echoices.fields.make_echoicefield(default=celery_growthmonitor.models.AJob.EStatus.ACTIVE, echoices=celery_growthmonitor.models.AJob.EStatus, editable=False)),
from .celery import app
@app.task
def my_task(holder: JobHolder, *args):
job = holder.get_job()
# Some processing
job.save()
return holder.pre_serialization()
Automatically set the job failed on task failure using custom base Task class
from celery_growthmonitor.models.task import JobFailedOnFailureTask
@app.task(base=JobFailedOnFailureTask, bind=True)
def my_task(self, holder: JobHolder):
pass
from django.contrib import admin
from celery_growthmonitor.admin import AJobAdmin
@admin.register(MyJob)
class MyJobAdmin(AJobAdmin):
fields = AJobAdmin.fields + ('my_extra_field',)
readonly_fields = AJobAdmin.readonly_fields + ('my_extra_field',)