Fynjy
8 months ago
1 changed files with 15 additions and 21 deletions
@ -1,21 +1,15 @@
|
||||
from __future__ import absolute_import, unicode_literals |
||||
import os |
||||
from celery import Celery |
||||
from celery.schedules import crontab |
||||
from crossposting_backend.tasks import delayed_post |
||||
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossposting_backend') |
||||
|
||||
app = Celery('crossposting_backend') |
||||
app.config_from_object('django.conf:settings', namespace='CELERY') |
||||
app.autodiscover_tasks() |
||||
|
||||
CELERY_BEAT_SCHEDULE = { |
||||
# Задача, которая будет выполнять отложенные публикации |
||||
'post-articles': { |
||||
'task': 'crossposting_backend.tasks.delayed_post', |
||||
'schedule': crontab(minute=0, hour='*'), # Запускать каждую минуту |
||||
'args': () # Аргументы задачи, в данном случае их нет |
||||
} |
||||
} |
||||
from __future__ import absolute_import, unicode_literals |
||||
import os |
||||
from celery import Celery |
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossposting_backend.settings') |
||||
|
||||
CELERY_TIMEZONE = 'Europe/Moscow' |
||||
|
||||
app = Celery('cms') |
||||
app.config_from_object('django.conf:settings', namespace='CELERY') |
||||
app.autodiscover_tasks() |
||||
|
||||
@app.task(bind=True) |
||||
def debug_task(self): |
||||
print(f'Request {self.request!r}') |
Loading…
Reference in new issue