Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cenphoenix/57d8ef64d0c3e6be9399292bdde3f6da to your computer and use it in GitHub Desktop.
Save cenphoenix/57d8ef64d0c3e6be9399292bdde3f6da to your computer and use it in GitHub Desktop.
@celery_app.task
def send_phone_code(user_id, verify_token, phone_number):
customer = Customer.objects.get(id=user_id)
#发送短信
send_message(...)
try:
# 通知任务完成
Group('phone_verify-%s' % customer.username).send({
'text': json.dumps({
'success': True,
'msg': 'new message sent'
})
})
except Exception as e:
# # 通知任务失败
Group('phone_verify-%s' % customer.username).send({
'text': json.dumps({
'success': False,
'msg': e.msg
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment