test_04_ApplicationFactory.py 文件源码

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

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def test_OrphanProcesses(self):
        """
        Tests that all child processes associated with a component get
        terminated with that component.
        """
        nb, domMgr = self.launchDomainManager()
        self.assertNotEqual(domMgr, None)

        nb, devMgr = self.launchDeviceManager('/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml')
        self.assertNotEqual(devMgr, None)

        domMgr.installApplication('/waveforms/orphaned_child/orphaned_child.sad.xml')

        appFact = domMgr._get_applicationFactories()[0]
        self.assertEqual(appFact._get_name(), 'orphaned_child')

        app = appFact.create(appFact._get_name(), [], [])
        pid = app._get_componentProcessIds()[0].processId
        children = [int(line) for line in commands.getoutput('ps --ppid %d --no-headers -o pid' % (pid,)).split()]

        app.releaseObject()

        orphans = 0
        for pid in children:
            try:
                os.kill(pid, 9)
                orphans += 1
            except OSError:
                pass

        self.assertEqual(orphans, 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号