MCPcopy
hub / github.com/pex-tool/pex / grab_ps

Function grab_ps

tests/integration/test_setproctitle.py:89–113  ·  view source on GitHub ↗
(
        pex,  # type: str
        *extra_pex_args  # type: str
    )

Source from the content-addressed store, hash-verified

87 build_pex_args.append("--venv")
88
89 def grab_ps(
90 pex, # type: str
91 *extra_pex_args # type: str
92 ):
93 # type: (...) -> Tuple[Text, Text]
94 run_pex_command(args=build_pex_args + ["-o", pex] + list(extra_pex_args)).assert_success()
95
96 process = subprocess.Popen(args=[sys.executable, pex, "--some", "arguments", "here"])
97 try:
98 # N.B.: We need to block on receiving the pid via fifo to prove that the PEX runtime has
99 # finished booting and completed any and all re-execs and landed in user code.
100 with open(pid_file) as fp:
101 assert process.pid == int(fp.read().strip())
102
103 exe, args = (
104 subprocess.check_output(
105 args=["ps", "-p", str(process.pid), "-o", "command=", "-ww"]
106 )
107 .decode("utf-8")
108 .strip()
109 .split(" ", 1)
110 )
111 return exe, args
112 finally:
113 process.kill()
114
115 def assert_expected_python(exe):
116 # type: (Text) -> None

Callers 1

test_setproctitleFunction · 0.85

Calls 6

run_pex_commandFunction · 0.90
assert_successMethod · 0.80
stripMethod · 0.80
decodeMethod · 0.80
readMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected