From e048e224d09baec5669a22a36d69ce130981db74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Thu, 24 Nov 2016 19:13:32 +0800 Subject: [PATCH] Do not return empty list if raise exception --- db_transfer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db_transfer.py b/db_transfer.py index 4656ef0..dcc158e 100644 --- a/db_transfer.py +++ b/db_transfer.py @@ -314,8 +314,9 @@ class DbTransfer(TransferBase): except Exception as e: logging.error(e) update_transfer = {} + finally: + conn.close() - conn.close() return update_transfer def pull_db_all_user(self): @@ -333,10 +334,8 @@ class DbTransfer(TransferBase): try: rows = self.pull_db_users(conn) - except Exception as e: - logging.error(e) - rows = [] - conn.close() + finally: + conn.close() if not rows: logging.warn('no user in db')