我正在运行一个celery任务,成功完成后就运行子任务以发送信号。
@celery.task(name='sendmail')
def send_async_email(msg):
return mail.send(msg)
def send_mail(msg):
// do some processing
send_async_email.apply_async((msg,), link=send_email_signal.s(msg))
@celery.task
def send_email_signal(result, email_type, msg):
email_sent_signal.send(msg, email_type=email_type)
signals.email_sent_signal.connect(track.track_emails_sent)
def track_emails_sent(msg):
// adds logs to logging system
问题是当我发送电子邮件时,一切正常,但是在日志系统中看到重复的条目。
我每收到一封电子邮件,因为芹菜花send_email_signal
运行了一次。但是在日志中,我们有2个日志条目。
我的芹菜盒里有多个芹菜工人。想了解如何处理celery回调任务发送的python信号。