2016-04-04 53 views
0
@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 

答えて

1

これはあなたの欲しいもののためのリンクです。 djangoの管理インターフェースを使用してcrontabを設定することができます。 タスクを開始するには2通りの方法があります:

スケジューラでは、毎回(例えば10秒間)または毎回(crontab doのように)タスクを呼び出します。 コードから、必要な場所に、必要な条件下で スケジューラによるタスクの起動 アドレスhttp:// {host}/admin/djcelery/periodictask /にある管理ページに移動し、[定期タスクを追加]を押します。

フィールドを下のスクリーンショットに示すように入力し、[保存]を押します。 enter image description here

起動周期タスクごとに10秒

は、前の場合のように、同じことを行う、代わりに期間の開始時刻を示しますが、クローンタブを埋めるために(間隔はブランクされなければならない): enter image description here

詳細詳細はhttp://www.lexev.org/en/2014/django-celery-setup/

関連する問題