Пример #1
0
 def test_multiprocessing_context_poll_raises_exception(self):
     mp_context = MultiprocessContext(
         name="test_mp",
         entrypoint=echo0,
         args={0: (0, 1)},
         envs={},
         stdouts={0: {}},
         stderrs={0: {}},
         tee_stdouts={0: "tee_stdout"},
         tee_stderrs={0: "tee_stderr"},
         error_files={0: "test_file"},
         start_method="spawn",
     )
     mp_context._pc = mock.Mock()
     # Using mock since we cannot just set exitcode on process
     mock_process = mock.Mock()
     mock_process.exitcode = -1
     mp_context._pc.processes = [mock_process]
     e = mp.ProcessRaisedException(msg="test msg", error_index=0, error_pid=123)
     mp_context._pc.join.side_effect = e
     with mock.patch.object(mp_context, "close"):
         run_result = mp_context._poll()
         self.assertEqual(1, len(run_result.failures))
         failure = run_result.failures[0]
         self.assertEqual("Signal 1 (SIGHUP) received by PID 123", failure.message)
 def test_errors_pickleable(self):
     for error in (
             mp.ProcessRaisedException("Oh no!", 1, 1),
             mp.ProcessExitedException("Oh no!", 1, 1, 1),
     ):
         pickle.loads(pickle.dumps(error))