(self)
| 732 | |
| 733 | @skip_unless_reliable_fork |
| 734 | def test_is_alive_after_fork(self): |
| 735 | # Try hard to trigger #18418: is_alive() could sometimes be True on |
| 736 | # threads that vanished after a fork. |
| 737 | old_interval = sys.getswitchinterval() |
| 738 | self.addCleanup(sys.setswitchinterval, old_interval) |
| 739 | |
| 740 | # Make the bug more likely to manifest. |
| 741 | test.support.setswitchinterval(1e-6) |
| 742 | |
| 743 | for i in range(20): |
| 744 | t = threading.Thread(target=lambda: None) |
| 745 | t.start() |
| 746 | # Ignore the warning about fork with threads. |
| 747 | with warnings.catch_warnings(category=DeprecationWarning, |
| 748 | action="ignore"): |
| 749 | if (pid := os.fork()) == 0: |
| 750 | os._exit(11 if t.is_alive() else 10) |
| 751 | else: |
| 752 | t.join() |
| 753 | |
| 754 | support.wait_process(pid, exitcode=10) |
| 755 | |
| 756 | def test_main_thread(self): |
| 757 | main = threading.main_thread() |
nothing calls this directly
no test coverage detected