Jan-10-2020, 09:55 AM
I don't like the idea the while True loop with a
if queue.Empty()
either. Instead, you can dotry: value = self.input_queue.get(timeout=0.1) except queue.Empty: continue else: ...The correct way to wait in threads is not to use
time.sleep()
statements. Instead you can wait with a timeout on queues or locks or condition objects, or perhaps use selectors that also wait with timeouts.