Commit 54268321 by 周杭

异常处理优化

1 parent f9a5c6b7
......@@ -110,13 +110,18 @@ def get_connection():
def execute_sql(sql):
conn = get_connection()
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
log.info("sql 执行结束")
try:
conn = get_connection()
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
log.info("sql 执行结束")
except Exception as msg:
log.error("sql执行Exception: " + str(msg))
finally:
cursor.close()
conn.close()
def generate_random_filename():
timestamp = int(time.time()) # 获取当前时间戳
......@@ -465,6 +470,6 @@ def consume_kafka():
log.info("handle_process耗时:"+str(end_time-start_time))
except Exception as e:
log.error("ocr consumer Exception: " + str(e))
finally:
# 关闭消费者
consumer.close()
# finally:
# # 关闭消费者
# consumer.close()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!