MCPcopy Index your code
hub / github.com/python/cpython / check_waitpid

Method check_waitpid

Lib/test/test_os/test_os.py:3210–3226  ·  view source on GitHub ↗
(self, code, exitcode, callback=None)

Source from the content-addressed store, hash-verified

3208
3209 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
3210 def check_waitpid(self, code, exitcode, callback=None):
3211 if sys.platform == 'win32':
3212 # On Windows, os.spawnv() simply joins arguments with spaces:
3213 # arguments need to be quoted
3214 args = [f'"{sys.executable}"', '-c', f'"{code}"']
3215 else:
3216 args = [sys.executable, '-c', code]
3217 pid = os.spawnv(os.P_NOWAIT, sys.executable, args)
3218
3219 if callback is not None:
3220 callback(pid)
3221
3222 # don't use support.wait_process() to test directly os.waitpid()
3223 # and os.waitstatus_to_exitcode()
3224 pid2, status = os.waitpid(pid, 0)
3225 self.assertEqual(os.waitstatus_to_exitcode(status), exitcode)
3226 self.assertEqual(pid2, pid)
3227
3228 def test_waitpid(self):
3229 self.check_waitpid(code='pass', exitcode=0)

Callers 4

test_waitpidMethod · 0.95
test_waitpid_windowsMethod · 0.95

Calls 2

callbackFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected