(self)
| 702 | |
| 703 | @support.requires_resource('walltime') |
| 704 | def test_many_processes(self): |
| 705 | if self.TYPE == 'threads': |
| 706 | self.skipTest('test not appropriate for {}'.format(self.TYPE)) |
| 707 | |
| 708 | sm = multiprocessing.get_start_method() |
| 709 | N = 5 if sm == 'spawn' else 100 |
| 710 | |
| 711 | # Try to overwhelm the forkserver loop with events |
| 712 | procs = [self.Process(target=self._test_sleep, args=(0.01,)) |
| 713 | for i in range(N)] |
| 714 | for p in procs: |
| 715 | p.start() |
| 716 | for p in procs: |
| 717 | join_process(p) |
| 718 | for p in procs: |
| 719 | self.assertEqual(p.exitcode, 0) |
| 720 | |
| 721 | procs = [self.Process(target=self._sleep_some) |
| 722 | for i in range(N)] |
| 723 | for p in procs: |
| 724 | p.start() |
| 725 | time.sleep(0.001) # let the children start... |
| 726 | for p in procs: |
| 727 | p.terminate() |
| 728 | for p in procs: |
| 729 | join_process(p) |
| 730 | if os.name != 'nt': |
| 731 | exitcodes = [-signal.SIGTERM] |
| 732 | if sys.platform == 'darwin': |
| 733 | # bpo-31510: On macOS, killing a freshly started process with |
| 734 | # SIGTERM sometimes kills the process with SIGKILL. |
| 735 | exitcodes.append(-signal.SIGKILL) |
| 736 | for p in procs: |
| 737 | self.assertIn(p.exitcode, exitcodes) |
| 738 | |
| 739 | def test_lose_target_ref(self): |
| 740 | c = DummyCallable() |
nothing calls this directly
no test coverage detected