в библиотеке django-q я написал код, который отправляет письмо раз в день
def send_statistics_email():
statistics = StatisticsNewletter.objects.all()
message = "Статистика отправленных сообщений:\n\n"
for stat in statistics:
message += str(stat) + "\n"
subject = "Статистика отправленных сообщений"
print('Letter sent')
send_mail(subject, message, settings.EMAIL_HOST_USER, [settings.RECIPIENT_ADDRESS])
schedule('notifications.views.send_statistics_email',schedule_type=Schedule.DAILY)
но он отправляет не 1 раз, а бесконечно
20:35:16 [Q] INFO Process-1 created a task from schedule [52]
20:35:16 [Q] INFO Enqueued 59
20:35:16 [Q] INFO Process-1 created a task from schedule [53]
20:35:16 [Q] INFO Enqueued 60
20:35:16 [Q] INFO Process-1 created a task from schedule [54]
20:35:16 [Q] INFO Enqueued 61
20:35:16 [Q] INFO Process-1 created a task from schedule [55]
20:35:17 [Q] INFO Process-1:1 processing [snake-rugby-fish-salami]
Letter sent
20:35:18 [Q] INFO Process-1:1 processing [eleven-blossom-south-fish]
Letter sent
20:35:18 [Q] INFO Processed [snake-rugby-fish-salami]
20:35:20 [Q] INFO Process-1:1 processing [sodium-item-quiet-blossom]
Letter sent
20:35:20 [Q] INFO Processed [eleven-blossom-south-fish]
20:35:21 [Q] INFO Process-1:1 processing [mobile-quiet-early-eleven]
Letter sent
20:35:21 [Q] INFO Processed [sodium-item-quiet-blossom]
20:35:22 [Q] INFO Process-1:1 processing [robin-spring-fanta-utah]
Letter sent
20:35:22 [Q] INFO Processed [mobile-quiet-early-eleven]
20:35:23 [Q] INFO Process-1:1 processing [artist-mexico-india-muppet]
Letter sent
20:35:24 [Q] INFO Processed [robin-spring-fanta-utah]
20:35:25 [Q] INFO Process-1:1 processing [bulldog-angel-aspen-hot]
Letter sent
20:35:25 [Q] INFO Processed [artist-mexico-india-muppet]
я думал дело в workers но стоит 1
Q_CLUSTER = {
'name': 'DjangORM',
'workers': 1,
'timeout': 90,
'retry': 120,
'queue_limit': 50,
'bulk': 10,
'orm': 'default',
'has_replica': True
}
пытался поставить другие значение
schedule_type='D',repeat=-1
без успешно