mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Retry reading state.json on failure.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1313
This commit is contained in:
parent
6f264ff5de
commit
ddaef1fb64
@ -382,15 +382,21 @@ class PollDebriefingFileThread(threading.Thread):
|
|||||||
else:
|
else:
|
||||||
last_modified = 0
|
last_modified = 0
|
||||||
while not self.stopped():
|
while not self.stopped():
|
||||||
if (
|
try:
|
||||||
os.path.isfile("state.json")
|
if (
|
||||||
and os.path.getmtime("state.json") > last_modified
|
os.path.isfile("state.json")
|
||||||
):
|
and os.path.getmtime("state.json") > last_modified
|
||||||
with open("state.json", "r") as json_file:
|
):
|
||||||
json_data = json.load(json_file)
|
with open("state.json", "r") as json_file:
|
||||||
debriefing = Debriefing(json_data, self.game, self.unit_map)
|
json_data = json.load(json_file)
|
||||||
self.callback(debriefing)
|
debriefing = Debriefing(json_data, self.game, self.unit_map)
|
||||||
break
|
self.callback(debriefing)
|
||||||
|
break
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
logging.exception(
|
||||||
|
"Failed to decode state.json. Probably attempted read while DCS "
|
||||||
|
"was still writing the file. Will retry in 5 seconds."
|
||||||
|
)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user