From 105498f501ed48145ba21470badc7fdcddcdd10c Mon Sep 17 00:00:00 2001 From: Jinwei Zhao Date: Tue, 31 Jan 2017 21:36:21 +0800 Subject: fix loop --- async_bot.py | 11 +++++------ ingrex/intel.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/async_bot.py b/async_bot.py index 51a347c..5c60503 100755 --- a/async_bot.py +++ b/async_bot.py @@ -187,8 +187,7 @@ def insert_message_to_database(time, id, msg): def main(): - # global intel - logger = logging.getLogger('main') + logger = logging.getLogger(__name__) # Lat & Lng of fetch region field = { @@ -211,7 +210,7 @@ def main(): except CookieException: logger.error(get_time() + ': Fetch Cookie Failed') time.sleep(3) - except Exception: + except: logger.error(get_time() + ": Unexpected error: " + str(sys.exc_info()[0]) + " " + str(inspect.currentframe().f_lineno)) time.sleep(3) @@ -224,7 +223,7 @@ def main(): with open('cookie') as cookies: cookies = cookies.read().strip() - + # fetch message per time while True: try: @@ -232,8 +231,8 @@ def main(): result = intel.fetch_msg(mints, maxts, reverse, tab) if result: mints = result[0][1] + 1 - break - except Exception: + break + except: logger.error(get_time() + ": Unexpected error: " + str(sys.exc_info()[0]) + " " + str(inspect.currentframe().f_lineno)) time.sleep(3) diff --git a/ingrex/intel.py b/ingrex/intel.py index 2cc4e7f..ca48bf0 100755 --- a/ingrex/intel.py +++ b/ingrex/intel.py @@ -43,7 +43,7 @@ class Intel(object): count = 0 while count < 3: try: - request = self.session.post(url, data=json.dumps(payload), headers=self.headers, timeout=(10, 60)) + request = self.session.post(url, data=json.dumps(payload), headers=self.headers, timeout=300) return request.json()['result'] except requests.ConnectionError: raise IntelException -- cgit v1.2.3