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())
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())