MCPcopy Index your code
hub / github.com/python/cpython / test_many_processes

Method test_many_processes

Lib/test/_test_multiprocessing.py:794–827  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

792 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
793 @support.requires_resource('walltime')
794 def test_many_processes(self):
795 if self.TYPE == 'threads':
796 self.skipTest('test not appropriate for {}'.format(self.TYPE))
797
798 sm = multiprocessing.get_start_method()
799 N = 5 if sm == 'spawn' else 100
800
801 # Try to overwhelm the forkserver loop with events
802 procs = [self.Process(target=self._test_sleep, args=(0.01,))
803 for i in range(N)]
804 for p in procs:
805 p.start()
806 for p in procs:
807 join_process(p)
808 for p in procs:
809 self.assertEqual(p.exitcode, 0)
810
811 procs = [self.Process(target=self._sleep_some)
812 for i in range(N)]
813 for p in procs:
814 p.start()
815 time.sleep(0.001) # let the children start...
816 for p in procs:
817 p.terminate()
818 for p in procs:
819 join_process(p)
820 if os.name != 'nt':
821 exitcodes = [-signal.SIGTERM]
822 if sys.platform == 'darwin':
823 # bpo-31510: On macOS, killing a freshly started process with
824 # SIGTERM sometimes kills the process with SIGKILL.
825 exitcodes.append(-signal.SIGKILL)
826 for p in procs:
827 self.assertIn(p.exitcode, exitcodes)
828
829 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
830 def test_lose_target_ref(self):

Callers

nothing calls this directly

Calls 11

join_processFunction · 0.85
skipTestMethod · 0.80
assertInMethod · 0.80
formatMethod · 0.45
get_start_methodMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
assertEqualMethod · 0.45
sleepMethod · 0.45
terminateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected