Terminates execution and cleans up the queues. If abort() was called before termination, this also terminates the subprocesses and doesn't wait for ongoing tests.
(self)
| 325 | self.os_context.terminate_process(p) |
| 326 | |
| 327 | def _terminate(self): |
| 328 | """Terminates execution and cleans up the queues. |
| 329 | |
| 330 | If abort() was called before termination, this also terminates the |
| 331 | subprocesses and doesn't wait for ongoing tests. |
| 332 | """ |
| 333 | if self.terminated: |
| 334 | return |
| 335 | self.terminated = True |
| 336 | |
| 337 | # Drain out work queue from tests |
| 338 | try: |
| 339 | while True: |
| 340 | self.work_queue.get(True, 0.1) |
| 341 | except Empty: |
| 342 | pass |
| 343 | |
| 344 | # Make sure all processes stop |
| 345 | for _ in self.processes: |
| 346 | # During normal tear down the workers block on get(). Feed a poison pill |
| 347 | # per worker to make them stop. |
| 348 | self.work_queue.put("STOP") |
| 349 | |
| 350 | # Send a SIGTERM to all workers. They will gracefully terminate their |
| 351 | # processing loop and if the signal is caught during job execution they |
| 352 | # will try to terminate the ongoing test processes quickly. |
| 353 | if self.abort_now: |
| 354 | self._terminate_processes() |
| 355 | |
| 356 | self.notify("Joining workers") |
| 357 | with drain_queue_async(self.done_queue): |
| 358 | for p in self.processes: |
| 359 | p.join() |
| 360 | |
| 361 | self.notify("Pool terminated") |
| 362 | |
| 363 | def _get_result_from_queue(self): |
| 364 | """Attempts to get the next result from the queue. |
no test coverage detected