MCPcopy Index your code
hub / github.com/RustPython/RustPython / _kill_process

Method _kill_process

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

Source from the content-addressed store, hash-verified

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

Callers 3

test_send_signalMethod · 0.95
test_killMethod · 0.95
test_terminateMethod · 0.95

Calls 2

getattrFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected