增加status.json加载失败时的容错处理.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
@@ -57,8 +58,12 @@ class QueryLog(BaseLog):
|
||||
if not Config.is_cluster_enabled() and path.exists(self.data_path):
|
||||
with open(self.data_path, encoding='utf-8') as f:
|
||||
result = f.read()
|
||||
if result:
|
||||
try:
|
||||
result = json.loads(result)
|
||||
except json.JSONDecodeError as e:
|
||||
self.add_quick_log('加载status.json失败, 文件内容为: {}.'.format(repr(result)))
|
||||
self.flush()
|
||||
result = {}
|
||||
|
||||
if Config.is_cluster_enabled():
|
||||
result = self.get_data_from_cluster()
|
||||
|
||||
Reference in New Issue
Block a user