Capture & log any errors in the state update worker

See #2715
This commit is contained in:
Gina Häußge committed 2018-07-05 10:58:45 +02:00
1 parent a97b8c2fd9
commit faff20943f
1 file changed
+15 -12
+15 -12
View File
@@ -1305,20 +1305,23 @@ class StateMonitor(object):
self._change_event.set()
def _work(self):
while True:
self._change_event.wait()
try:
while True:
self._change_event.wait()
now = time.time()
delta = now - self._last_update
additional_wait_time = self._interval - delta
if additional_wait_time > 0:
time.sleep(additional_wait_time)
now = time.time()
delta = now - self._last_update
additional_wait_time = self._interval - delta
if additional_wait_time > 0:
time.sleep(additional_wait_time)
with self._state_lock:
data = self.get_current_data()
self._update_callback(data)
self._last_update = time.time()
self._change_event.clear()
with self._state_lock:
data = self.get_current_data()
self._update_callback(data)
self._last_update = time.time()
self._change_event.clear()
except:
logging.getLogger(__name__).exception("Looks like something crashed inside the state update worker. Please report this on the OctoPrint issue tracker (make sure to include logs!)")
def get_current_data(self):
with self._progress_lock: