将signal与celery 结合的异步signal

保存触发此函数,然后调用异步消息队列

from lawyer_assistant.celery import app
from notifications.models import Notification
# 触发消息——提醒
@app.task
def meal_handler(sender, instance, created,is_asynchronous=False, **kwargs):  
  """   
 :param sender:   
 :param instance:    
 :param created:   
 :param kwargs:   
 :return:   
 """
from  ce.tasks import meal_handler
#律所保存触发此函数,然后调用异步消息队列
@receiver(post_save, sender=LawFirm)
def delay_to_save(sender, instance, created, **kwargs):   
    t = meal_handler.s(sender=sender, instance=instance,created=created,is_asynchronous=True)    
    t.delay()

你可能感兴趣的:(将signal与celery 结合的异步signal)