fix bug when restarting statemachine

fixed bad if clause
+ better debug message on restart/stop
This commit is contained in:
zolliker 2022-09-20 10:31:43 +02:00
parent 54f091d0fe
commit 07995e2235

View File

@ -132,7 +132,8 @@ class StateMachine:
:return: None (for custom cleanup functions this might be a new state) :return: None (for custom cleanup functions this might be a new state)
""" """
if state.stopped: # stop or restart if state.stopped: # stop or restart
state.log.debug('%sed in state %r', repr(state.stopped).lower(), state.status_string) verb = 'stopped' if state.stopped is Stop else 'restarted'
state.log.debug('%s in state %r', verb, state.status_string)
else: else:
state.log.warning('%r raised in state %r', state.last_error, state.status_string) state.log.warning('%r raised in state %r', state.last_error, state.status_string)
@ -196,7 +197,7 @@ class StateMachine:
self.log.debug('called %r %sexc=%r', self.cleanup, self.log.debug('called %r %sexc=%r', self.cleanup,
'ret=%r ' % ret if ret else '', e) 'ret=%r ' % ret if ret else '', e)
if ret is None: if ret is None:
self.log.debug('state: None') self.log.debug('state: None after cleanup')
self.state = None self.state = None
self._idle_event.set() self._idle_event.set()
return None return None