added state api
This commit is contained in:
@@ -47,6 +47,9 @@ def add_default_jobs(sched=None, testing=False):
|
||||
check_recorder_state_job = sched.add_job(recorder_checker.check_object_state, 'interval', minutes=2,
|
||||
id="check_recorder_state_job")
|
||||
|
||||
"""
|
||||
Job regularly sending the state to "frontend recorders" through websocket
|
||||
"""
|
||||
send_update_state_to_recorder_job = sched.add_job(
|
||||
lambda: send_state_update_to_recorders(recorder_checker.get_current_state()), 'interval', minutes=1,
|
||||
id="send_update_state_to_recorder_job")
|
||||
|
||||
@@ -22,6 +22,11 @@ T = TypeVar('T')
|
||||
|
||||
|
||||
class StateChecker(Generic[T]):
|
||||
"""
|
||||
This class is designed generically to regularly check the state of objects with given function(s).
|
||||
The determined state is stored "locally" in the state checker object and NOT reflected back to the checked objects!
|
||||
It can be retrieved by calling get_current_state.
|
||||
"""
|
||||
def __init__(self, state_checker_func: Union[Callable, List[Callable]], type_to_check: T, type_name=None,
|
||||
threads=NUM_THREADS):
|
||||
self.num_threads = threads
|
||||
@@ -135,7 +140,6 @@ class StateChecker(Generic[T]):
|
||||
'previous': {'state_ok': self.state_results[o_s]['state_ok'],
|
||||
'msg': self.state_results[o_s].get('msg', None),
|
||||
'time_stamp': self.state_results[o_s].get('time_stamp', None)}}
|
||||
pass
|
||||
else:
|
||||
self.state_results[o_s] = object_states[o_s]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user