如何在芹菜中添加新任务而不停止芹菜实例在django芹菜?

问题描述:

@shared_task 
def forgot_email(subject,user_cipher,key_cipher,to): 
    print "comes here in the mail" 
    try: 
     email_content = {'user_cipher':user_cipher,'key_cipher': key_cipher} 
     message = render_to_string('forgot_password.txt',email_content) 
     send_mail(subject, message, settings.EMAIL,to, fail_silently=False) 
     except Exception,e: 
     print "Exception",e 
    except: 
     print 'exp' 

@shared_task 
def multiplesendmail(subject,body,first_name,to): 
    print "comes here in the mail" 
    try: 
     print 'subject',subject,'body',body,'first_name',first_name,'to',to 
     # email_content = {'first_name':first_name,'user_cipher':user_cipher,'key_cipher':key_cipher} 
     # message = render_to_string('email_verification.txt', email_content) 
     send_mail(subject,body,settings.EMAIL,to,fail_silently=False) 
    except Exception,e: 
     print "Exception",e 

注 - 我想添加一个新任务而不停止芹菜。我必须使用这个第一站芹菜然后如何在芹菜中添加新任务而不停止芹菜实例在django芹菜?

celery -A HealthBrio worker -l info 

这是一个你想要的链接。您可以使用django的管理界面设置crontab。 有两种启动任务的方式:

调度程序会在每个时间段(例如10秒)或每个特定时间(如crontab)调用任务。 来自代码,在需要的地方,在需要的条件下。 由调度程序启动任务 转至地址为http:// {host}/admin/djcelery/periodictask /的管理页面,然后按“添加周期性任务”。

填充字段,如下面的屏幕截图所示,然后按保存。 enter image description here

启动周期性任务每10秒

为了表示推出的时间,而不是一段,做同样的,在前面的情况,但填写的crontab(间隔必须为空白。): enter image description here

更多详细信息在http://www.lexev.org/en/2014/django-celery-setup/