(self)
| 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() |
nothing calls this directly
no test coverage detected