From 33bd0eb2410b24d463631b3fd5a545abe0e92ebb Mon Sep 17 00:00:00 2001 From: gateray <437925289@qq.com> Date: Thu, 12 Oct 2017 15:38:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92=E7=9A=84?= =?UTF-8?q?bug=202.=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1=E6=B6=88?= =?UTF-8?q?=E6=81=AF=EF=BC=8Credis=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=97=B6=E5=AF=BC=E8=87=B4=E6=B6=88=E6=81=AF=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 3 +-- models.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 7ba439e..a8bf2aa 100644 --- a/app.py +++ b/app.py @@ -23,9 +23,8 @@ def getRedisConn(self): redisConn.connect() self.redisConn = redisConn return self.redisConn - except Exception: + except: self.redisConn = None - raise def getSMTPConn(self): try: import smtplib diff --git a/models.py b/models.py index d179f45..cd6ee82 100644 --- a/models.py +++ b/models.py @@ -36,7 +36,7 @@ def send(self): class WeiXinQYMessage(Message): def __init__(self, redisConn, title="", content="", **qywxSettings): - super(WeiXinQYMessage, self).__init__(title, content) + super(WeiXinQYMessage, self).__init__(title=title, content=content) self.baseUrl = qywxSettings.get("baseUrl") self.corpid = qywxSettings.get("corpid") self.corpsecret = qywxSettings.get("corpsecret") @@ -62,7 +62,10 @@ def refreshToken(self): return "" try: accessToken = json.loads(response.body).get("access_token") - yield tornado.gen.Task(self.__redis.setex, redisKeys["WXQY_ACCESS_TOKEN"], 7200, accessToken) + try: + yield tornado.gen.Task(self.__redis.setex, redisKeys["WXQY_ACCESS_TOKEN"], 7200, accessToken) + except: + pass return accessToken except json.JSONDecodeError: print("JSON decode error, fail to get access_token.")