未验证 提交 e5034707 编写于 作者: C Chen Weihang 提交者: GitHub

try multi times for sys.exit (#30188)

上级 619c62bb
...@@ -41,18 +41,27 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase): ...@@ -41,18 +41,27 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
def test_child_process_exit_with_error(self): def test_child_process_exit_with_error(self):
def __test_process__(): def __test_process__():
core._set_process_signal_handler() core._set_process_signal_handler()
os._exit(os.EX_DATAERR) sys.exit(1)
def try_except_exit():
exception = None exception = None
try: try:
test_process = multiprocessing.Process(target=__test_process__) test_process = multiprocessing.Process(target=__test_process__)
test_process.start() test_process.start()
set_child_signal_handler(id(self), test_process.pid) set_child_signal_handler(id(self), test_process.pid)
time.sleep(10) time.sleep(5)
except SystemError as ex: except SystemError as ex:
self.assertIn("Fatal", cpt.get_exception_message(ex)) self.assertIn("Fatal", cpt.get_exception_message(ex))
exception = ex exception = ex
return exception
try_time = 10
exception = None
for i in range(try_time):
exception = try_except_exit()
if exception is not None:
break
self.assertIsNotNone(exception) self.assertIsNotNone(exception)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册