feat: base 提供监测celery的实例

This commit is contained in:
caoqianming 2024-03-13 17:37:46 +08:00
parent 38b7d0c586
commit a891692b71
1 changed files with 4 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import os
from . import conf
from celery import Celery
from celery.app.control import Control, Inspect
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
@ -16,6 +17,9 @@ app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
celery_control: Control = Control(app=app)
celery_inspect: Inspect = celery_control.inspect()
@app.task(bind=True)
def debug_task(self):