From b51976defcea19bd0c5d14299eb263e8d4c89c56 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 15 Jul 2019 17:03:30 +0800 Subject: [PATCH] fix some error --- ad_interface_tornado.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 52ef58c..33621fc 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -62,7 +62,7 @@ def send_cache_data(): # 检查num是否已达到设定数值 num = my_redis.get(f"{key}:num") if not num: - num=0 + num = 0 if line['ad_num'] > 0 and line['ad_num'] <= num: # 该广告已播放达到次数,从缓存中清除 my_redis.srem(key, line['id']) @@ -97,17 +97,19 @@ class DispatchHandler(tornado.web.RequestHandler): def _selfGetAdList(self): input = json.loads(self.get_query_argument('body')) gameid = input['gameid'] - localid = input['localid'] - key = f"{gameid}::{localid}" + locationid = input['locationid'] + key = f"{gameid}::{locationid}" ids = my_redis.smembers(key) info = [] - pdb.set_trace() - for id in ids: - keys=f"{id}::info" - temp = my_redis.hgetall(f"{id}::info") - info.append(temp) - result={'code':200,"message":{"totoal":len(info),"result":json.dumps(info)}} - self.write(result) + try: + for id in ids: + temp = my_redis.hgetall(f"{id}::info") + info.append(temp) + result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": json.dumps(info)}} + except Exception as e: + result = {'errcode': 1, "errmsg": e} + finally: + self.write(result) def make_app():