def send_sms_code(mobile, sms_code, expires): print('发送短信任务函数被调用[mobile: %s sms_code: %s]' % (mobile, sms_code)) try: ccp = CCP() res = ccp.send_template_sms(mobile, [sms_code, expires], SMS_CODE_TEMP_ID) except Exception as e: logger.error("发送验证码短信[异常][ mobile: %s, message: %s ]" % (mobile, e)) else: if res != 0: # 发送短信失败 logger.warning("发送验证码短信[失败][ mobile: %s ]" % mobile) else: # 发送短信成功 logger.info("发送验证码短信[正常][ mobile: %s ]" % mobile)
def send_sms_code(mobile, sms_code): CCP().send_template_sms(mobile, [sms_code, 5], 1) sleep(5) print('发送短信验证码:', sms_code)
def send_sms_code(mobile, sms_code): """ 利用celery异步发送短信 :param mobile: 要收到短信的手机号 :param sms_code: 短信验证码 """ CCP().send_template_sms(mobile, [sms_code, 5], 1)
def send_sms_code(mobile, sms_code): """ 发送短信的celery异步任务 :param mobile:手机号 :param sms_code: 验证码 """ CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60], 1) # //表示整除
def send_sms_code(mobile, sms_code, expires): print('[celery]第三方发送短信开始 --> [mobile: %s]-[验证码: %s]' % (mobile, sms_code)) try: res_code = CCP().send_template_sms(mobile, [sms_code, expires], SMS_CODE_TEMP_ID) except BaseException as e: logger.error('[celery]第三方发送短信异常 --> [mobile: %s]-[验证码: %s]' % (mobile, sms_code)) else: if res_code: logger.error('[celery]第三方发送短信失败 --> [mobile: %s]-[验证码: %s]' % (mobile, sms_code)) else: logger.info('[celery]第三方发送短信成功 --> [mobile: %s]-[验证码: %s]' % (mobile, sms_code)) # @celery_app.task(name='send_verify_email') # def send_verify_email(email,verify_url): # print('发送邮件被调用') # subject = "Story邮箱验证" # html_message = '<p>尊敬的用户您好!</p>' \ # '<p>感谢您使用Story。</p>' \ # '<p>您的邮箱为:%s 。请点击此链接激活您的邮箱:</p>' \ # '<p><a href="%s">%s<a></p>' % (email, verify_url, verify_url) # send_mail(subject, "", '开发者<*****@*****.**>', [email], html_message=html_message)
def send_sms_code(mobile, sms_code): # 定义发短信的方法 """ 利用celery异步发送短信 :param mobile: 要收到短信的手机号 :param sms_code: 短信验证码 """ CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_EXPIRE // 60], constants.SMS_TEMPLATE_ID)
def send_sms_code(mobile, sms_code): """ 发送短信异步任务 :param mobile: 手机号 :param sms_code: 短信验证码 :return: None """ CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60], 1)
def send_sms_code(mobile, sms_code): """ 发送短信的异步任务 mobile: sms_code: """ CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60], constants.SEND_SMS_CODE_INTERVAL)
def send_sms_code(mobile, sms_code): """ :param mobile: 手机号 :param sms_code: 短信验证码 :return: 成功0或者失败-1 """ CCP().send_template_sms(mobile, [sms_code, 5], 1)
def send_sms_code(mobile, sms_code): """ 发送短信异步任务 :param mobile: 手机号 :param sms_code: 短信验证码 :return: 成功0 或 失败-1 """ # 给当前手机号发短信 # CCP().send_template_sms(要收短信的手机号, [短信验证码, 短信中提示的过期时间单位分钟], 短信模板id) CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60], constants.SEND_SMS_TEMPLATE_ID)
def send_sms_code(mobile, sms_code, expires): """发送短信的任务函数""" try: res = CCP().send_template_sms(mobile, [sms_code, expires], SMS_CODE_TEMP_ID) except Exception as e: logger.error("发送验证码短信[异常][ mobile: %s, message: %s ]" % (mobile, e)) else: if res != 0: logger.warning("发送验证码短信[失败][ mobile: %s ]" % mobile) else: logger.info("发送验证码短信[正常][ mobile: %s ]" % mobile)
def send_sms_code(mobile, sms_code, expires): try: res = CCP().send_template_sms(mobile, [sms_code, expires], SMS_CODE_TEMP_ID) except Exception as e: logger.error('发送短信异常: [mobile: %s] [sms_code: %s]' % (mobile, sms_code)) else: if res != 0: # 发送短信失败 logger.error('发送短信失败: [mobile: %s] [sms_code: %s]' % (mobile, sms_code)) else: # 发送短信成功 logging.info('发送短信成功: [mobile: %s] [sms_code: %s]' % (mobile, sms_code))
def send_sms_code(mobile, sms_code, expires): print('发送短信的任务函数被调用') try: res = CCP().send_template_sms(mobile, [sms_code, expires], SMS_CODE_TEMP_ID) except Exception as e: logger.error('发送短信异常:[mobile: %s]-[sms_code: %s]' % (mobile, sms_code)) else: if res != 0: logger.error('发送短信失败:[mobile: %s]-[sms_code: %s]' % (mobile, sms_code)) else: logger.info('发送短信成功:[mobile: %s]-[sms_code: %s]' % (mobile, sms_code))
def ccp_send_sms_code(self, mobile, sms_code): try: print('mobile:', mobile) print('sms_code:', sms_code) #发送成功返回0,发送失败返回-1 sen_data = CCP().send_template_sms(mobile, [sms_code, 5], 1) except Exception as e: logger.error(e) #有异常最多重试此数,重试三次 raise self.retry(exc=e, max_retries=3) if sen_data != 0: #有异常自动重试次数 raise self.retry(exc=Exception('发送短信失败'), max_retries=3) return sen_data
def send_sms_code(mobile, sms_code, expires): # 任务函数代码 try: res = CCP().send_template_sms(mobile, [sms_code, expires], SMS_CODE_TEMP_ID) except Exception as e: logger.error('发送短信异常:[mobile: %s]-[sms_code: %s]' % (mobile, sms_code)) # return Response({'message': '发送短信异常'}, status=status.HTTP_503_SERVICE_UNAVAILABLE) 因为服务器此时的作用就是发送一个任务,然后就继续自己的执行,这个函数的执行是通过worker完成的,所以此时就不需要返回响应给服务器了 else: if res != 0: logger.error('发送短信失败:[mobile: %s]-[sms_code: %s]' % (mobile, sms_code)) else: logger.error('发送短信成功:[mobile: %s]-[sms_code: %s]' % (mobile, sms_code))
def send_sms_code(self, mobile, sms_code): """ 发送短信验证码的异步任务 :param self: :param mobile: 手机号 :param sms_code: 验证码 :return: 成功0,失败-1 """ try: # time.sleep(300) send_res = CCP().send_template_sms(tid, mobile, (sms_code, sms_time)) except Exception as e: logger.error('[send_sms_code] {}'.format(e)) raise self.retry(exc=e, max_retries=3) return send_res
def send_sms_code(mobile, sms_code, expires): # 任务函数代码 try: res = CCP().send_template_sms(mobile, [sms_code, expires], SEND_SMS_TEMP_ID) except Exception as e: logger.error('短信验证码发送异常:[mobile:%s sms_code:%s]' % (mobile, sms_code)) else: if res != 0: # 短信发送失败 logger.error('短信验证码发送失败:[mobile:%s sms_code:%s]' % (mobile, sms_code)) else: logger.info('短信验证码发送成功:[mobile:%s sms_code:%s]' % (mobile, sms_code))
def send_sms_code(mobile, sms_code, expires): """发送短信的任务函数""" try: res = CCP().send_template_sms(mobile, [sms_code, expires], SEND_SMS_TEMP_ID) except Exception: # 发送短信异常 logger.error('发送短信异常:[mobile: %s] [sms_code_%s]' % (mobile, sms_code)) else: if res != 0: # 发送短信失败 logger.error('发送短信失败:[mobile: %s] [sms_code_%s]' % (mobile, sms_code)) else: # 发送短信成功 logger.info('发送短信成功:[mobile: %s] [sms_code_%s]' % (mobile, sms_code))
def send_sms_code(mobile, sms_code, expires): """ 发送短信验证码 :param mobile: 手机号 :param code: 验证码 :param expires: 有效期 :return: None """ # 任务函数代码.. try: res = CCP().send_template_sms(mobile, [sms_code, expires], SEND_SMS_TEMP_ID) except Exception as e: logger.error('验证码发送异常:[mobile:%s, sms_code:%s]' % (mobile, sms_code)) else: if res != 0: # 短信发送失败 logger.error('验证码发送失败了:[mobile:%s, sms_code:%s]' % (mobile, sms_code)) else: logger.info('短信验证码发送成功:[mobile:%s, sms_code:%s]' % (mobile, sms_code))
def send_sms_code(mobile, sms_code): CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_EXPIRE_REDIS // 60], 1)
def send_sms_code(mobile, sms_code): CCP().send_template_sms(mobile, [sms_code, 5], 1)
def ccp_send_sms_code(mobile, sms_code): CCP().send_template_sms(mobile, [sms_code, 5], 996)
def send_sms_code(mobile, sms_code): # 利用第三方容联云发短信 CCP().send_template_sms(mobile, [sms_code, constants.SNS_CODE_EXPIRE_REDIS // 60], 1)
from celery_tasks.sms.yuntongxun.sms import CCP
def send_sms_code(mobile, sms_code): # 给当前手机号发短信 # CCP().send_template_sms(要收短信的手机号, [短信验证码, 短信中提示的过期时间单位分钟], 短信模板id) CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60], 1)
def send_sms_code(mobile, sms_code): """发送短信异步任务""" CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES//60], constants.SMS_CODE_TEMP_ID)
def send_sms_code(mobile, sms_code): """异步发送短信任务""" CCP().send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60], constants.SEND_SMS_TEMPLATE_ID)
from celery_tasks.sms.yuntongxun.sms import CCP
def send_sms_code(mobile, sms_code, time_min, template_id): CCP().send_template_sms(mobile, [sms_code, time_min], template_id)
# 编写任务代码的py