Why doesn't celery send an email at the specified time?

喜你入骨 提交于 2021-01-29 08:35:30

问题


I sent mail an hour before the event (the model in django), checked the date check in shell, but celery does not send any mail or print to the console. I have a feeling that I didn't finish writing something, because I haven't worked with the planned actions yet. but there are no ideas. I didn't connect it anywhere shedule.py perhaps this is the reason

tasks.py:

@shared_task
def event_send_mail():
    events = Event.objects.filter(event_date=datetime.now() + timedelta(minutes=60))
    for event in events:
        print("Событие")
        send_mail("Напоминание о событии", str(event.title) + "начинаеся через час",
                                     "marsel.abdullin.00@mail.ru", [event.user.email, ])

shedule.py:

CELERYBEAT_SCHEDULE = {
    'send_mail': {
        'task': 'tasks.event_send_mail',
        'schedule': timedelta(minutes=1),
    },
}

settings.py:

CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"

来源:https://stackoverflow.com/questions/62801096/why-doesnt-celery-send-an-email-at-the-specified-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!