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

Method _kill_process

Lib/test/test_subprocess.py:2566–2589  ·  view source on GitHub ↗
(self, method, *args)

Source from the content-addressed store, hash-verified

2564 self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
2565
2566 def _kill_process(self, method, *args):
2567 # Do not inherit file handles from the parent.
2568 # It should fix failures on some platforms.
2569 # Also set the SIGINT handler to the default to make sure it's not
2570 # being ignored (some tests rely on that.)
2571 old_handler = signal.signal(signal.SIGINT, signal.default_int_handler)
2572 try:
2573 p = subprocess.Popen([sys.executable, "-c", """if 1:
2574 import sys, time
2575 sys.stdout.write('x\\n')
2576 sys.stdout.flush()
2577 time.sleep(30)
2578 """],
2579 close_fds=True,
2580 stdin=subprocess.PIPE,
2581 stdout=subprocess.PIPE,
2582 stderr=subprocess.PIPE)
2583 finally:
2584 signal.signal(signal.SIGINT, old_handler)
2585 # Wait for the interpreter to be completely initialized before
2586 # sending any signal.
2587 p.stdout.read(1)
2588 getattr(p, method)(*args)
2589 return p
2590
2591 @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')),
2592 "Due to known OS bug (issue #16762)")

Callers 3

test_send_signalMethod · 0.95
test_killMethod · 0.95
test_terminateMethod · 0.95

Calls 1

readMethod · 0.45

Tested by

no test coverage detected