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

Method _kill_with_event

Lib/test/test_os.py:2870–2901  ·  view source on GitHub ↗
(self, event, name)

Source from the content-addressed store, hash-verified

2868
2869 @unittest.skipIf(mmap is None, "requires mmap")
2870 def _kill_with_event(self, event, name):
2871 tagname = "test_os_%s" % uuid.uuid1()
2872 m = mmap.mmap(-1, 1, tagname)
2873 m[0] = 0
2874
2875 # Run a script which has console control handling enabled.
2876 script = os.path.join(os.path.dirname(__file__),
2877 "win_console_handler.py")
2878 cmd = [sys.executable, script, tagname]
2879 proc = subprocess.Popen(cmd,
2880 creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
2881
2882 with proc:
2883 # Let the interpreter startup before we send signals. See #3137.
2884 for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
2885 if proc.poll() is None:
2886 break
2887 else:
2888 # Forcefully kill the process if we weren't able to signal it.
2889 proc.kill()
2890 self.fail("Subprocess didn't finish initialization")
2891
2892 os.kill(proc.pid, event)
2893
2894 try:
2895 # proc.send_signal(event) could also be done here.
2896 # Allow time for the signal to be passed and the process to exit.
2897 proc.wait(timeout=support.SHORT_TIMEOUT)
2898 except subprocess.TimeoutExpired:
2899 # Forcefully kill the process if we weren't able to signal it.
2900 proc.kill()
2901 self.fail("subprocess did not stop on {}".format(name))
2902
2903 @unittest.skip("subprocesses aren't inheriting Ctrl+C property")
2904 @support.requires_subprocess()

Callers 2

test_CTRL_C_EVENTMethod · 0.95
test_CTRL_BREAK_EVENTMethod · 0.95

Calls 7

pollMethod · 0.95
killMethod · 0.95
waitMethod · 0.95
joinMethod · 0.45
failMethod · 0.45
killMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected