| Total Complexity | 4 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| 1 | import queue |
||
| 5 | class LogPrinterThread(threading.Thread): |
||
| 6 | """ |
||
| 7 | This is the Thread object that outputs all log messages it gets from |
||
| 8 | its message_queue. Setting obj.running = False will stop within the next |
||
| 9 | 0.1 seconds. |
||
| 10 | """ |
||
| 11 | def __init__(self, message_queue, log_printer): |
||
| 12 | threading.Thread.__init__(self) |
||
| 13 | self.running = True |
||
| 14 | self.message_queue = message_queue |
||
| 15 | self.log_printer = log_printer |
||
| 16 | |||
| 17 | def run(self): |
||
| 18 | while self.running: |
||
| 19 | try: |
||
| 20 | elem = self.message_queue.get(timeout=0.1) |
||
| 21 | self.log_printer.log_message(elem) |
||
| 22 | except queue.Empty: |
||
| 23 | pass |
||
| 24 |