used by chief to allow workers to run or not
| 159 | |
| 160 | |
| 161 | class TrafficLight: |
| 162 | """used by chief to allow workers to run or not""" |
| 163 | |
| 164 | def __init__(self, val=True): |
| 165 | self.val = mp.Value("b", False) |
| 166 | self.lock = mp.Lock() |
| 167 | |
| 168 | def get(self): |
| 169 | with self.lock: |
| 170 | return self.val.value |
| 171 | |
| 172 | def switch(self): |
| 173 | with self.lock: |
| 174 | self.val.value = (not self.val.value) |
| 175 | |
| 176 | |
| 177 | class Counter: |