本文整理汇总了Python中pyon.ion.process.IonProcessThread.start_listeners方法的典型用法代码示例。如果您正苦于以下问题:Python IonProcessThread.start_listeners方法的具体用法?Python IonProcessThread.start_listeners怎么用?Python IonProcessThread.start_listeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.ion.process.IonProcessThread
的用法示例。
在下文中一共展示了IonProcessThread.start_listeners方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_heartbeat_listener_dead
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import start_listeners [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)
示例2: test_heartbeat_with_listeners
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import start_listeners [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)
示例3: test_spawn_proc_with_one_listener
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import start_listeners [as 别名]
def test_spawn_proc_with_one_listener(self):
mocklistener = Mock(spec=ProcessRPCServer)
p = IonProcessThread(name=sentinel.name, listeners=[mocklistener])
readyev = Event()
readyev.set()
mocklistener.get_ready_event.return_value = readyev
p.start()
p.get_ready_event().wait(timeout=5)
p.start_listeners()
self.assertEquals(len(p.thread_manager.children), 2)
mocklistener.listen.assert_called_once_with(thread_name=ANY)
self.assertEqual(mocklistener.routing_call, p._routing_call)
p._notify_stop()
mocklistener.close.assert_called_once_with()
p.stop()
示例4: test_spawn_with_listener_failure
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import start_listeners [as 别名]
def test_spawn_with_listener_failure(self):
mocklistener = Mock(spec=ProcessRPCServer)
mocklistener.listen.side_effect = self.ExpectedFailure
readyev = Event()
readyev.set()
mocklistener.get_ready_event.return_value = readyev
p = IonProcessThread(name=sentinel.name, listeners=[mocklistener])
p.start()
p.get_ready_event().wait(timeout=5)
p.start_listeners()
# the exception is linked to the main proc inside the IonProcess, so that should be dead now
self.assertTrue(p.proc.dead)
self.assertIsInstance(p.proc.exception, self.ExpectedFailure)
# stopping will raise an error as proc died already
self.assertRaises(self.ExpectedFailure, p._notify_stop)
# make sure control flow proc died though
self.assertTrue(p.thread_manager.children[-1].proc.dead)
p.stop()