celery & attributes list by product
This commit is contained in:
44
Rasaddam_Backend/celery.py
Normal file
44
Rasaddam_Backend/celery.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
import os
|
||||
from celery.schedules import crontab
|
||||
from celery import Celery
|
||||
import django
|
||||
from django.conf import settings
|
||||
|
||||
# Set the default Django settings module for the 'celery' program.
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Rasaddam_Backend.settings")
|
||||
|
||||
django.setup()
|
||||
|
||||
app = Celery("Rasaddam_Backend")
|
||||
|
||||
# Using a string here means the worker doesn't have to serialize
|
||||
# the configuration object to child processes.
|
||||
# - namespace='CELERY' means all celery-related configuration keys
|
||||
# should have a `CELERY_` prefix.
|
||||
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||
|
||||
"""
|
||||
celery beat conf
|
||||
"""
|
||||
app.conf.beat_schedule = {}
|
||||
|
||||
# Load task modules from all registered Django apps.
|
||||
app.autodiscover_tasks()
|
||||
|
||||
|
||||
@app.task(bind=True, ignore_result=True)
|
||||
def debug_task(self):
|
||||
print(f"Request: {self.request!r}")
|
||||
|
||||
|
||||
"""
|
||||
celery beat conf
|
||||
"""
|
||||
app.conf.beat_schedule = {
|
||||
'add-every-30-seconds': {
|
||||
'task': 'apps.authentication.tasks.task_func',
|
||||
'schedule': 5.0,
|
||||
# 'args': (16, 16),
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user