Commit f190ec86 authored by Guillaume Seguin's avatar Guillaume Seguin

Always sleep a little bit in status checker thread

parent 0b8113ba
...@@ -1308,15 +1308,18 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1308,15 +1308,18 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.send_now("M105") self.p.send_now("M105")
cur_time = time.time() cur_time = time.time()
wait_time = 0 wait_time = 0
while time.time() < cur_time + self.monitor_interval: while time.time() < cur_time + self.monitor_interval - 0.25:
if not self.statuscheck: if not self.statuscheck:
break break
time.sleep(0.25) time.sleep(0.25)
# Safeguard: if system time changes and goes back in the past, # Safeguard: if system time changes and goes back in the past,
# we could get stuck almost forever # we could get stuck almost forever
wait_time += 0.25 wait_time += 0.25
if wait_time > self.monitor_interval: if wait_time > self.monitor_interval - 0.25:
break break
# Always sleep at least a bit, if something goes wrong with the
# system time we'll avoid freezing the whole app this way
time.sleep(0.25)
try: try:
while not self.sentlines.empty(): while not self.sentlines.empty():
gc = self.sentlines.get_nowait() gc = self.sentlines.get_nowait()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment