Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions package/bin/state_store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os.path as op
import os
import json
import sys
import json
from json import JSONDecodeError

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib import client

Expand Down Expand Up @@ -50,10 +52,14 @@ def get_state(self):
fname = op.join(self.checkpoint_dir, self.key)
if op.exists(fname):
with open(fname) as jsonfile:
state = json.load(jsonfile)
# commented this to disable state cache for local file
# self._states_cache[key] = state
return state
try:
state = json.load(jsonfile)
# commented this to disable state cache for local file
# self._states_cache[key] = state
return state
except JSONDecodeError:
return None

else:
return None

Expand Down