'Monitor the queue for records, and ask the handler
to deal with them.
This method runs on a separate, internal thread.
The thread will terminate if it sees a sentinel object in the queue.'

def _monitor(self):

    q = self.queue
    has_task_done = hasattr(q, 'task_done')
    while (not self._stop.isSet()):
        try:
            record = self.dequeue(True)
            if (record is self._sentinel):
                break
            self.handle(record)
            if has_task_done:
                q.task_done()
        except queue.Empty:
            pass
    while True:
        try:
            record = self.dequeue(False)
            if (record is self._sentinel):
                break
            self.handle(record)
            if has_task_done:
                q.task_done()
        except queue.Empty:
            break
