@MAGistr_MTM
Учусь программировать

Что не так с Селерой(Celery)?

Доброго времени суток.
У меня проблема с некоторими тасками с Селеры.
Вот у меня есть такая таска:
from django.core.management import call_command

from celery import shared_task


@shared_task
def send_order_review_emails():
    call_command('review_emails')

И вот конфиг Селеры:
CELERYBEAT_SCHEDULE = {
    'send_order_review_emails': {
        'task': 'apps.catalogue.tasks.send_order_review_emails',
        'schedule': crontab(hour=5, minute=0)
    }
}

Тоесть, таска должна выполнятся один раз в 5 часов утра. Но на практике оно не так:
[2018-09-14 05:00:00,044: INFO/MainProcess] Received task: apps.catalogue.tasks.send_order_review_emails[6b6335c3-0dc2-482f-b0b5-ecfd36ee06b7]
[2018-09-14 05:00:00,047: WARNING/Worker-2] Checking orders
[2018-09-14 05:00:00,056: WARNING/Worker-2] Completed.
[2018-09-14 05:00:00,057: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[6b6335c3-0dc2-482f-b0b5-ecfd36ee06b7] succeeded in 0.0121419355273s: None
[2018-09-14 05:00:00,097: INFO/Beat] Scheduler: Sending due task send_order_review_emails (apps.catalogue.tasks.send_order_review_emails)
[2018-09-14 05:03:00,052: INFO/MainProcess] Received task: apps.catalogue.tasks.send_order_review_emails[8553a102-dc14-4e28-ad46-6602f9984515]
[2018-09-14 05:03:00,055: WARNING/Worker-2] Checking orders
[2018-09-14 05:03:00,066: WARNING/Worker-2] Completed.
[2018-09-14 05:03:00,066: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[8553a102-dc14-4e28-ad46-6602f9984515] succeeded in 0.0133577734232s: None
[2018-09-14 05:05:00,061: INFO/MainProcess] Received task: apps.catalogue.tasks.send_order_review_emails[f67b50a9-906f-4290-9a3b-66f311295d10]
[2018-09-14 05:05:00,062: WARNING/Worker-2] Checking orders
[2018-09-14 05:05:00,073: WARNING/Worker-2] Completed.
[2018-09-14 05:05:00,073: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[f67b50a9-906f-4290-9a3b-66f311295d10] succeeded in 0.0117091722786s: None
[2018-09-14 05:06:00,045: INFO/MainProcess] Received task: apps.catalogue.tasks.send_order_review_emails[543c5bc1-6f4f-475e-a254-5fd52df321ac]
[2018-09-14 05:06:00,048: WARNING/Worker-2] Checking orders
[2018-09-14 05:06:00,058: WARNING/Worker-2] Completed.
[2018-09-14 05:06:00,058: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[543c5bc1-6f4f-475e-a254-5fd52df321ac] succeeded in 0.0120799578726s: None
...
[2018-09-14 05:11:00,118: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[93070d02-52d6-4a61-9491-b628a7e4faa2] succeeded in 0.0735367536545s: None
[2018-09-14 05:11:12,436: INFO/Beat] Scheduler: Sending due task check_new_label (apps.dashboard.catalogue.tasks.check_new_label)
[2018-09-14 05:11:12,440: INFO/MainProcess] Received task: apps.dashboard.catalogue.tasks.check_new_label[e2b66fb3-dadd-43bb-9702-7843e318777e]
[2018-09-14 05:11:12,443: WARNING/Worker-2] Checking products
[2018-09-14 05:11:12,641: WARNING/Worker-2] Changed 0 labels
[2018-09-14 05:11:12,641: WARNING/Worker-2] Completed.
[2018-09-14 05:11:12,644: INFO/MainProcess] Task apps.dashboard.catalogue.tasks.check_new_label[e2b66fb3-dadd-43bb-9702-7843e318777e] succeeded in 0.203036315739s: None
...
[2018-09-14 05:59:00,048: INFO/MainProcess] Received task: apps.catalogue.tasks.send_order_review_emails[56f987c3-2724-40ee-8880-222451ee1094]
[2018-09-14 05:59:00,049: WARNING/Worker-2] Checking orders
[2018-09-14 05:59:00,060: WARNING/Worker-2] Completed.
[2018-09-14 05:59:00,061: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[56f987c3-2724-40ee-8880-222451ee1094] succeeded in 0.0121172629297s: None
[2018-09-14 06:11:12,568: INFO/Beat] Scheduler: Sending due task check_new_label (apps.dashboard.catalogue.tasks.check_new_label)
[2018-09-14 06:11:12,571: INFO/MainProcess] Received task: apps.dashboard.catalogue.tasks.check_new_label[e8befc2f-2413-45b8-9a9f-1ba52297e467]
[2018-09-14 06:11:12,572: WARNING/Worker-2] Checking products
[2018-09-14 06:11:13,175: WARNING/Worker-2] Changed 0 labels
[2018-09-14 06:11:13,176: WARNING/Worker-2] Completed.
[2018-09-14 06:11:13,180: INFO/MainProcess] Task apps.dashboard.catalogue.tasks.check_new_label[e8befc2f-2413-45b8-9a9f-1ba52297e467] succeeded in 0.608058463782s: None

Почему-то, таска выполняется с интервалом 1-3 минуты. В чем может быть проблема?
Благодарен за помощь.

===================================UPD================================
Только что сменил на дев сервере(Селера только там), настройки таски на:
'send_order_review_emails': {
        'task': 'apps.catalogue.tasks.send_order_review_emails',
        'schedule': crontab(hour=14, minute=0)
    }

И таска запустилась только один раз:
[2018-09-14 13:56:00,491: INFO/Beat] beat: Starting...
[2018-09-14 13:56:00,512: INFO/MainProcess] Connected to redis+redis://socket%3A%2F%2F%2Ftmp%2Fredis.sock%3Fvirtual_host%3D1:6379//
[2018-09-14 13:56:00,526: INFO/MainProcess] mingle: searching for neighbors
[2018-09-14 13:56:01,532: INFO/MainProcess] mingle: all alone
[2018-09-14 13:56:01,540: WARNING/MainProcess] celery@devel.vetopharm.qg ready.
[2018-09-14 14:00:00,065: INFO/Beat] Scheduler: Sending due task send_order_review_emails (apps.catalogue.tasks.send_order_review_emails)
[2018-09-14 14:00:00,069: INFO/MainProcess] Received task: apps.catalogue.tasks.send_order_review_emails[228f065d-51d3-4cb9-991a-84aaba49f7f4]
[2018-09-14 14:00:00,076: INFO/Beat] Scheduler: Sending due task create_supply_orders (apps.supplier_communication.tasks.create_supply_orders)
[2018-09-14 14:00:00,118: WARNING/Worker-2] Checking orders
[2018-09-14 14:00:00,131: WARNING/Worker-2] Completed.
[2018-09-14 14:00:00,141: INFO/MainProcess] Task apps.catalogue.tasks.send_order_review_emails[228f065d-51d3-4cb9-991a-84aaba49f7f4] succeeded in 0.0623154342175s: None
  • Вопрос задан
  • 406 просмотров
Пригласить эксперта
Ответы на вопрос 2
@vikholodov
Цитат из доки:
A string representing a Crontab pattern. This may get pretty advanced, like hour='*/3' (for every three hours) or hour='0,8-17/2' (at midnight, and every two hours during office hours).
Ответ написан
@VanVanuch
Без обид, но Вы уверены, что никто не задал в переопределении settings,
старт для таска 'apps.catalogue.tasks.send_order_review_emails' crontab(minute=3) ?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы