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


Python IonProcessThread.cancel_or_abort_call方法代码示例

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


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

示例1: test__control_flow_cancelled_call

# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import cancel_or_abort_call [as 别名]
    def test__control_flow_cancelled_call(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)

        # put a call in that will never finish
        waitar = AsyncResult()      # test specific, wait for this to indicate we're being processed/hung
        callar = AsyncResult()      # test specific, an ar that is just waited on by the spin call (eventually set in this test)
        def spin(inar, outar):
            outar.set(True)
            inar.wait()

        ar = p._routing_call(spin, MagicMock(), callar, waitar)

        # schedule a second call that we're going to cancel
        futurear = AsyncResult()
        ar2 = p._routing_call(futurear.set, MagicMock(), sentinel.val)

        # wait until we get notice we're being processed
        waitar.get(timeout=2)

        # cancel the SECOND call
        p.cancel_or_abort_call(ar2)

        # prove we didn't interrupt the current proc by allowing it to continue
        callar.set()
        ar.get(timeout=2)

        # now the second proc will get queued and never called because it is cancelled
        self.assertRaises(Timeout, futurear.get, timeout=2)
        self.assertTrue(ar2.ready())
开发者ID:mkl-,项目名称:scioncc,代码行数:35,代码来源:test_process.py


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