test_devices.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:tasker 作者: wavenator 项目源码 文件源码
def test_lost_case_remote_killer(self):
        test_process_obj = TestProcess()
        testing_process = multiprocessing.Process(
            target=test_process_obj.lost,
            kwargs={
                'interval': 30,
            },
        )
        testing_process.daemon = True
        testing_process.start()

        self.assertTrue(testing_process.is_alive())

        remote_killer = devices.killer.RemoteKiller(
            pid=testing_process.pid,
            soft_timeout=1.0,
            soft_timeout_signal=signal.SIGINT,
            hard_timeout=2.0,
            hard_timeout_signal=signal.SIGABRT,
            critical_timeout=3.0,
            critical_timeout_signal=signal.SIGTERM,
            memory_limit=4 * 1024 * 1024 * 1024,
            memory_limit_signal=signal.SIGINT,
        )

        remote_killer.start()
        self.assertTrue(testing_process.is_alive())
        time.sleep(1.2)
        self.assertTrue(testing_process.is_alive())
        time.sleep(1.2)
        self.assertTrue(testing_process.is_alive())
        time.sleep(1.2)
        self.assertFalse(testing_process.is_alive())
        self.assertEqual(testing_process.exitcode, -15)
        remote_killer.stop()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号