LogPrinterThread   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 5 1
A run() 0 7 3
1
import queue
2
import threading
3
4
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