当前位置: 首页>>代码示例>>Python>>正文


Python IonProcessThread.heartbeat方法代码示例

本文整理汇总了Python中pyon.ion.process.IonProcessThread.heartbeat方法的典型用法代码示例。如果您正苦于以下问题:Python IonProcessThread.heartbeat方法的具体用法?Python IonProcessThread.heartbeat怎么用?Python IonProcessThread.heartbeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.ion.process.IonProcessThread的用法示例。


在下文中一共展示了IonProcessThread.heartbeat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_heartbeat_current_op_over_limit

# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import heartbeat [as 别名]
    def test_heartbeat_current_op_over_limit(self):
        self.patch_cfg('pyon.ion.process.CFG', {'container':{'timeout':{'heartbeat_proc_count_threshold':2}}})

        svc = self._make_service()
        p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
        p.start()
        p.get_ready_event().wait(timeout=5)
        p._ctrl_thread.ev_exit.set()            # prevent heartbeat loop in proc's target

        def fake_op(evout, evin):
            evout.set(True)
            evin.wait()

        listenoutev = AsyncResult()
        listeninev = Event()

        self.addCleanup(listeninev.set)     # allow graceful termination
        self.addCleanup(p.stop)

        ar = p._routing_call(fake_op, None, listenoutev, listeninev)

        listenoutev.wait(timeout=5)         # wait for ctrl thread to run our op

        # make sure it's over the threshold
        for x in xrange(3):
            hb = p.heartbeat()

        self.assertEquals((True, True, False), hb)
开发者ID:mkl-,项目名称:scioncc,代码行数:30,代码来源:test_process.py

示例2: test_heartbeat_with_current_op_multiple_times

# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import heartbeat [as 别名]
    def test_heartbeat_with_current_op_multiple_times(self):
        svc = self._make_service()
        p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
        p.start()
        p.get_ready_event().wait(timeout=5)
        p._ctrl_thread.ev_exit.set()            # prevent heartbeat loop in proc's target

        def fake_op(evout, evin):
            evout.set(True)
            evin.wait()

        listenoutev = AsyncResult()
        listeninev = Event()

        self.addCleanup(listeninev.set)     # allow graceful termination
        self.addCleanup(p.stop)

        ar = p._routing_call(fake_op, None, listenoutev, listeninev)

        listenoutev.wait(timeout=5)         # wait for ctrl thread to run our op

        for x in xrange(5):
            hb = p.heartbeat()

        self.assertEquals((True, True, True), hb)
        self.assertEquals(5, p._heartbeat_count)
        self.assertEquals(ar, p._heartbeat_op)
开发者ID:mkl-,项目名称:scioncc,代码行数:29,代码来源:test_process.py

示例3: test_heartbeat_with_listeners

# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import heartbeat [as 别名]
    def test_heartbeat_with_listeners(self):
        mocklistener = Mock(spec=ProcessRPCServer)
        svc = self._make_service()
        p = IonProcessThread(name=sentinel.name, listeners=[mocklistener], service=svc)
        readyev = Event()
        readyev.set()
        mocklistener.get_ready_event.return_value = readyev

        def fake_listen(evout, evin):
            evout.set(True)
            evin.wait()

        listenoutev = AsyncResult()
        listeninev = Event()

        mocklistener.listen = lambda *a, **kw: fake_listen(listenoutev, listeninev)

        p.start()
        p.get_ready_event().wait(timeout=5)
        p.start_listeners()

        listenoutev.wait(timeout=5)         # wait for listen loop to start

        self.addCleanup(listeninev.set)     # makes listen loop fall out on shutdown
        self.addCleanup(p.stop)

        # now test heartbeat!
        hb = p.heartbeat()

        self.assertEquals((True, True, True), hb)
        self.assertEquals(0, p._heartbeat_count)
        self.assertIsNone(p._heartbeat_op)
开发者ID:mkl-,项目名称:scioncc,代码行数:34,代码来源:test_process.py

示例4: test_heartbeat_listener_dead

# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import heartbeat [as 别名]
    def test_heartbeat_listener_dead(self):
        mocklistener = Mock(spec=ProcessRPCServer)
        svc = self._make_service()
        p = IonProcessThread(name=sentinel.name, listeners=[mocklistener], service=svc)
        readyev = Event()
        readyev.set()
        mocklistener.get_ready_event.return_value = readyev

        def fake_listen(evout, evin):
            evout.set(True)
            evin.wait()

        listenoutev = AsyncResult()
        listeninev = Event()

        p.start()
        p.get_ready_event().wait(timeout=5)
        p.start_listeners()

        listenoutev.wait(timeout=5)         # wait for listen loop to start

        self.addCleanup(listeninev.set)     # makes listen loop fall out on shutdown
        self.addCleanup(p.stop)

        listeninev.set()                    # stop the listen loop
        p.thread_manager.children[1].join(timeout=5)        # wait for listen loop to terminate

        hb = p.heartbeat()

        self.assertEquals((False, True, True), hb)
        self.assertEquals(0, p._heartbeat_count)
        self.assertIsNone(p._heartbeat_op)
开发者ID:mkl-,项目名称:scioncc,代码行数:34,代码来源:test_process.py

示例5: test_heartbeat_no_listeners

# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import heartbeat [as 别名]
    def test_heartbeat_no_listeners(self):
        svc = self._make_service()
        p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
        p.start()
        p.get_ready_event().wait(timeout=5)
        self.addCleanup(p.stop)

        hb = p.heartbeat()

        self.assertEquals((True, True, True), hb)
        self.assertEquals(0, p._heartbeat_count)
        self.assertIsNone(p._heartbeat_op)
开发者ID:mkl-,项目名称:scioncc,代码行数:14,代码来源:test_process.py


注:本文中的pyon.ion.process.IonProcessThread.heartbeat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。