Ejemplo n.º 1
0
        def _deco(ch, method, properties, body):
            try:
                context.RequestContext()
                log.info("开始执行业务方法")
                func(ch, method, properties, body)
            except Exception as e:
                print(e)
                if conf.env == 'conf':
                    mail_title = Utils.currentTime() + " " + sys.argv[0] + "执行异常,异常内容见邮件"
                    Utils.sendMail(mail_title, traceback.format_exc(), [
                        '邮箱地址'
                    ])
                else:
                    traceback.print_exc()
                log.info("业务方法异常")

            finally:
                log.info("队列消息确认消费")
                ch.basic_ack(delivery_tag=method.delivery_tag)
Ejemplo n.º 2
0
 def _deco(client, userdata, msg):
     try:
         print("\n" + Utils.currentTime() + " 开始执行业务方法")
         func(client, userdata, msg)
     except Exception as e:
         print("业务方法异常")