本文整理汇总了Python中pyon.ion.process.IonProcessThread._routing_call方法的典型用法代码示例。如果您正苦于以下问题:Python IonProcessThread._routing_call方法的具体用法?Python IonProcessThread._routing_call怎么用?Python IonProcessThread._routing_call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.ion.process.IonProcessThread
的用法示例。
在下文中一共展示了IonProcessThread._routing_call方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__control_flow_expired_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test__control_flow_expired_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)
def make_call(call, ctx, val):
ar = p._routing_call(call, ctx, val)
return ar.get(timeout=10)
ctx = { 'reply-by' : 0 } # no need for real time, as it compares by CURRENT >= this value
futurear = AsyncResult()
with patch('pyon.ion.process.greenlet') as gcm:
waitar = AsyncResult()
gcm.getcurrent().kill.side_effect = lambda *a, **k: waitar.set()
ar = p._routing_call(futurear.set, ctx, sentinel.val)
waitar.get(timeout=10)
# futurear is not set
self.assertFalse(futurear.ready())
# neither is the ar we got back from routing_call
self.assertFalse(ar.ready())
# we should've been killed, though
self.assertEquals(gcm.getcurrent().kill.call_count, 1)
self.assertIsInstance(gcm.getcurrent().kill.call_args[1]['exception'], IonTimeout)
# put a new call through (to show unblocked)
futurear2 = AsyncResult()
ar2 = p._routing_call(futurear2.set, MagicMock(), sentinel.val2)
ar2.get(timeout=2)
示例2: test__interrupt_control_thread
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test__interrupt_control_thread(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
def spin(inar, outar):
outar.set(True)
inar.wait()
ar = p._routing_call(spin, MagicMock(), callar, waitar)
# wait until we get notice we're being processed
waitar.get(timeout=2)
# interrupt it
p._interrupt_control_thread()
# the ar we got back from routing_call will not be set, it never finished the call
self.assertFalse(ar.ready())
# to prove we're unblocked, run another call through the control thread
ar2 = p._routing_call(callar.set, MagicMock(), sentinel.val)
ar2.get(timeout=2)
self.assertTrue(callar.ready())
self.assertEquals(callar.get(), sentinel.val)
示例3: test__control_flow_cancelled_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_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())
示例4: test__routing_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test__routing_call(self):
svc = self._make_service()
p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
p.start()
p.get_ready_event().wait(timeout=5)
ar = AsyncResult()
p._routing_call(ar.set, None, value=sentinel.callarg)
v = ar.get(timeout=5)
self.assertEquals(v, sentinel.callarg)
p._notify_stop()
p.stop()
示例5: test__routing_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test__routing_call(self):
svc = LocalContextMixin()
p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
p.start()
p.get_ready_event().wait(timeout=5)
ar = AsyncResult()
p._routing_call(ar.set, {'value':sentinel.callarg})
v = ar.get(timeout=5)
self.assertEquals(v, sentinel.callarg)
p._notify_stop()
p.stop()
示例6: test_heartbeat_current_op_over_limit
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [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)
示例7: test_heartbeat_with_current_op_multiple_times
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [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)
示例8: test__cancel_pending_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test__cancel_pending_call(self):
svc = self._make_service()
p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
ar = p._routing_call(sentinel.call, MagicMock())
val = p._cancel_pending_call(ar)
self.assertTrue(val)
self.assertTrue(ar.ready())
示例9: test_has_pending_call_with_no_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test_has_pending_call_with_no_call(self):
svc = self._make_service()
p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
ar = p._routing_call(sentinel.call, MagicMock())
# pretend we've processed it
p._ctrl_queue.get()
self.assertFalse(p.has_pending_call(ar))
示例10: test_competing__routing_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test_competing__routing_call(self):
svc = self._make_service()
p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
p.start()
p.get_ready_event().wait(timeout=5)
sem = Semaphore()
# define a callable method that tries to grab a shared semaphore
def thecall(ar=None):
semres = sem.acquire(blocking=False)
if not semres:
raise StandardError("Could not get semaphore, routing_call/control flow is broken!")
# make this take a sec
time.sleep(1)
# make sure we release
sem.release()
# set the ar
ar.set(True)
# schedule some calls (in whatever order)
ar1 = AsyncResult()
ar2 = AsyncResult()
ar3 = AsyncResult()
p._routing_call(thecall, None, ar=ar3)
p._routing_call(thecall, None, ar=ar1)
p._routing_call(thecall, None, ar=ar2)
# wait on all the ARs to be set
ar1.get(timeout=5)
ar2.get(timeout=5)
ar3.get(timeout=5)
# just getting here without throwing an exception is the true test!
p._notify_stop()
p.stop()
示例11: test_has_pending_call
# 需要导入模块: from pyon.ion.process import IonProcessThread [as 别名]
# 或者: from pyon.ion.process.IonProcessThread import _routing_call [as 别名]
def test_has_pending_call(self):
svc = self._make_service()
p = IonProcessThread(name=sentinel.name, listeners=[], service=svc)
ar = p._routing_call(sentinel.call, MagicMock())
self.assertTrue(p.has_pending_call(ar))