waits for the process to complete, handles the exit code
(self)
| 2612 | os.close(self._stdin_parent_fd) |
| 2613 | |
| 2614 | def wait(self): |
| 2615 | """waits for the process to complete, handles the exit code""" |
| 2616 | |
| 2617 | self.log.debug("acquiring wait lock to wait for completion") |
| 2618 | # using the lock in a with-context blocks, which is what we want if |
| 2619 | # we're running wait() |
| 2620 | with self._wait_lock: |
| 2621 | self.log.debug("got wait lock") |
| 2622 | witnessed_end = False |
| 2623 | |
| 2624 | if self.exit_code is None: |
| 2625 | self.log.debug("exit code not set, waiting on pid") |
| 2626 | pid, exit_code = no_interrupt(os.waitpid, self.pid, 0) # blocks |
| 2627 | self.exit_code = handle_process_exit_code(exit_code) |
| 2628 | witnessed_end = True |
| 2629 | |
| 2630 | else: |
| 2631 | self.log.debug( |
| 2632 | "exit code already set (%d), no need to wait", self.exit_code |
| 2633 | ) |
| 2634 | self._process_exit_cleanup(witnessed_end=witnessed_end) |
| 2635 | return self.exit_code |
| 2636 | |
| 2637 | def _process_exit_cleanup(self, witnessed_end): |
| 2638 | self._quit_threads.set() |