MCPcopy
hub / github.com/amoffat/sh / wait

Method wait

src/sh/__init__.py:2614–2635  ·  view source on GitHub ↗

waits for the process to complete, handles the exit code

(self)

Source from the content-addressed store, hash-verified

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()

Callers 15

waitMethod · 0.45
wait_for_completionMethod · 0.45
input_threadFunction · 0.45
event_waitFunction · 0.45
background_threadFunction · 0.45
output_threadFunction · 0.45
test_multiple_pipesMethod · 0.45
test_backgroundMethod · 0.45
test_stdout_callbackMethod · 0.45

Calls 4

_process_exit_cleanupMethod · 0.95
no_interruptFunction · 0.85
handle_process_exit_codeFunction · 0.85
debugMethod · 0.80