33 lines
819 B
Python
33 lines
819 B
Python
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
import os
|
|
|
|
from celery import Celery
|
|
from django.conf import settings
|
|
|
|
from . import celeryconfig
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.development')
|
|
|
|
app = Celery('config',
|
|
broker=celeryconfig.broker_url,
|
|
backend=celeryconfig.result_backend)
|
|
|
|
app.config_from_object("config.celeryconfig")
|
|
app.autodiscover_tasks(settings.INSTALLED_APPS)
|
|
|
|
|
|
@app.task(bind=True)
|
|
def debug_task(self):
|
|
print('Request: {0!r}'.format(self.request))
|
|
|
|
from celery.schedules import crontab
|
|
|
|
app.conf.beat_schedule = {
|
|
# 'scan_images_to_convert_into_webp_format': {
|
|
# 'task': 'products.tasks.scan_images_to_convert_into_webp_format',
|
|
# 'schedule': crontab(minute='*/5'), # Executes every 5 minutes
|
|
# },
|
|
}
|