Total Complexity | 3 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | """Utility package for threads |
||
19 | class StoppableThread(Thread): |
||
20 | """A thread with the ability to be remotely stopped |
||
21 | """ |
||
22 | |||
23 | def __init__(self): |
||
24 | Thread.__init__(self) |
||
25 | self.stop_event = Event() |
||
26 | |||
27 | def is_stopped(self): |
||
28 | """Test if a thread is stopped |
||
29 | |||
30 | Returns |
||
31 | bool: True if stopped, False otherwise |
||
32 | """ |
||
33 | return self.stop_event.isSet() |
||
34 | |||
35 | def stop(self): |
||
36 | """Stop the thread |
||
37 | """ |
||
38 | self.stop_event.set() |
||
39 |