try to fix reader and signal test failed (#30960)

revert-31068-fix_conv3d_windows
Chen Weihang 5 years ago committed by GitHub
parent 3ba69809bf
commit 010f2caa23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -68,7 +68,7 @@ TEST(BlockingQueue, SenderBlockingTest) {
++send_count; ++send_count;
} }
}); });
std::this_thread::sleep_for(std::chrono::milliseconds(200)); std::this_thread::sleep_for(std::chrono::milliseconds(1000));
q.Close(); q.Close();
sender.join(); sender.join();
EXPECT_EQ(send_count, queue_cap); EXPECT_EQ(send_count, queue_cap);

@ -70,16 +70,26 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
core._set_process_signal_handler() core._set_process_signal_handler()
os.kill(os.getpid(), signal.SIGSEGV) os.kill(os.getpid(), signal.SIGSEGV)
exception = None def try_except_exit():
try: exception = None
test_process = multiprocessing.Process(target=__test_process__) try:
test_process.start() test_process = multiprocessing.Process(target=__test_process__)
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("Segmentation fault", cpt.get_exception_message(ex)) self.assertIn("Segmentation fault",
exception = ex cpt.get_exception_message(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)
@ -88,16 +98,25 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
core._set_process_signal_handler() core._set_process_signal_handler()
os.kill(os.getpid(), signal.SIGBUS) os.kill(os.getpid(), signal.SIGBUS)
exception = None def try_except_exit():
try: exception = None
test_process = multiprocessing.Process(target=__test_process__) try:
test_process.start() test_process = multiprocessing.Process(target=__test_process__)
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("Bus error", cpt.get_exception_message(ex)) self.assertIn("Bus error", 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)

Loading…
Cancel
Save