From 43ecffc2d97874e634e925043804beceb5366b7c Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 15 Jul 2019 16:21:07 +0800 Subject: [PATCH] fix some error --- ad_interface_tornado.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index c00c0f9..421d8be 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -35,7 +35,7 @@ def send_cache_data(): item = {} try: item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item['ad_url'], \ - item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line + item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line all.append(item) except Exception: log.error("split data failed", exc_info=True) @@ -50,7 +50,7 @@ def send_cache_data(): item = {} try: item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item['ad_url'], \ - item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line + item['ad_sort'], item['companyid'], item['locationid'], item['gameid'] = line all.append(item) except Exception: log.error("split data failed", exc_info=True) @@ -60,7 +60,10 @@ def send_cache_data(): key = f"{line.get('gameid', 0)}::{line.get('locationid', 0)}" if my_redis.exists(key): # 检查num是否已达到设定数值 - num = my_redis.get(f"{key}:num") or 0 + num = my_redis.get(f"{key}:num") + if not num: + num=0 + print("num was ",num) if line['num'] != -1 and line['num'] <= num: # 该广告已播放达到次数,从缓存中清除 my_redis.srem(key, line['id'])