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

Method test_is_alive_after_fork

Lib/test/test_threading.py:686–706  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

684 @unittest.skip('TODO: RUSTPYTHON; flaky')
685 @skip_unless_reliable_fork
686 def test_is_alive_after_fork(self):
687 # Try hard to trigger #18418: is_alive() could sometimes be True on
688 # threads that vanished after a fork.
689 old_interval = sys.getswitchinterval()
690 self.addCleanup(sys.setswitchinterval, old_interval)
691
692 # Make the bug more likely to manifest.
693 test.support.setswitchinterval(1e-6)
694
695 for i in range(20):
696 t = threading.Thread(target=lambda: None)
697 t.start()
698 # Ignore the warning about fork with threads.
699 with warnings.catch_warnings(category=DeprecationWarning,
700 action="ignore"):
701 if (pid := os.fork()) == 0:
702 os._exit(11 if t.is_alive() else 10)
703 else:
704 t.join()
705
706 support.wait_process(pid, exitcode=10)
707
708 def test_main_thread(self):
709 main = threading.main_thread()

Callers

nothing calls this directly

Calls 5

startMethod · 0.95
is_aliveMethod · 0.95
joinMethod · 0.95
addCleanupMethod · 0.80
_exitMethod · 0.45

Tested by

no test coverage detected