- self._q = queue.Queue()
- self._t = threading.Thread(target=self.queue_consumer)
- self._t.start()
-
- def queue_consumer(self):
- while True:
- el = self._q.get()
- if el is None: return # we are supposed to terminate
- # handle the state change
- (oldstate, newstate) = el
- self.callback(oldstate, newstate)