Total Complexity | 4 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 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 | |||
12 | def __init__(self, message_queue, log_printer): |
||
13 | threading.Thread.__init__(self) |
||
14 | self.running = True |
||
15 | self.message_queue = message_queue |
||
16 | self.log_printer = log_printer |
||
17 | |||
18 | def run(self): |
||
19 | while self.running: |
||
20 | try: |
||
21 | elem = self.message_queue.get(timeout=0.1) |
||
22 | self.log_printer.log_message(elem) |
||
23 | except queue.Empty: |
||
24 | pass |
||
25 |