最近我一直在通過軟件開發攪拌,並且順利地將芹菜彎曲成我的意志。芹菜難度:功能對象沒有屬性'延遲'
我已經成功地使用它發送電子郵件,並試圖使用幾乎完全相同的代碼(在重新啓動所有進程等後)通過Twilio發送短信。
不過,我不斷收到了以下問題:
File "/Users/Rob/Dropbox/Python/secTrial/views.py", line 115, in send_sms
send_sms.delay(recipients, form.text.data)
AttributeError: 'function' object has no attribute 'delay'
我的代碼如下:從我views.py調用時
@celery.task
def send_email(subject, sender, recipients, text_body):
msg = Message(subject, sender=sender)
for email in recipients:
msg.add_recipient(email)
msg.body = text_body
mail.send(msg)
@celery.task
def send_sms(recipients, text_body):
for number in recipients:
print number
num = '+61' + str(number)
print num
msg = text_body + 'this message to' + num
client.messages.create(to=num, from_="+14804054823", body=msg)
send_email.delay完美的作品,但是send_sms.delay失敗每次都有上述錯誤。
任何幫助解決這個問題表示讚賞。
- 按照要求:
@app.route('/send_mail', methods=['GET', 'POST'])
@roles_accepted('Admin')
def send_mail():
form = SendMailForm(request.form)
if request.method == 'POST':
if form.validate_on_submit():
emails = db.session.query(User.email).all()
list_emails = list(zip(*emails)[0])
send_email.delay('Subject', '[email protected]', list_emails, form.text.data)
return render_template('send_generic.html', form=form)
@app.route('/send_sms', methods=['GET', 'POST'])
@roles_accepted('Admin')
def send_sms():
form = SendMailForm(request.form)
if request.method == 'POST':
if form.validate_on_submit():
recipients = db.session.query(User.mobile).all()
list_recipients = filter(None, list(zip(*recipients)[0]))
send_sms.delay(list_recipients, form.text.data)
return render_template('send_generic.html', form=form, send_sms=send_sms)
我send_sms芹菜裝飾功能被顯示爲一個註冊任務:
和配置我只是使用guest:RabbitMQ的
CELERY_BROKER_URL = 'amqp://[email protected]//'
CELERY_RESULT_BACKEND = 'amqp://[email protected]//'
你可以發佈你的芹菜配置和意見? – ChillarAnand 2014-10-16 17:30:38