OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 from multiprocessing import Event, Process, Queue | 6 from multiprocessing import Event, Process, Queue |
7 | 7 |
8 class NormalResult(): | 8 class NormalResult(): |
9 def __init__(self, result): | 9 def __init__(self, result): |
10 self.result = result | 10 self.result = result |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 # they empty the queue buffer. | 127 # they empty the queue buffer. |
128 self.done.set() | 128 self.done.set() |
129 | 129 |
130 for p in self.processes: | 130 for p in self.processes: |
131 # During normal tear down the workers block on get(). Feed a poison pill | 131 # During normal tear down the workers block on get(). Feed a poison pill |
132 # per worker to make them stop. | 132 # per worker to make them stop. |
133 self.work_queue.put("STOP") | 133 self.work_queue.put("STOP") |
134 | 134 |
135 for p in self.processes: | 135 for p in self.processes: |
136 p.join() | 136 p.join() |
| 137 |
| 138 # Drain the queues to prevent failures when queues are garbage collected. |
| 139 try: |
| 140 while True: self.work_queue.get(False) |
| 141 except: |
| 142 pass |
| 143 try: |
| 144 while True: self.done_queue.get(False) |
| 145 except: |
| 146 pass |
OLD | NEW |