Exemplo n.º 1
0
    def test_async_result(self):
        request_id = "request_foo"
        waiter = AsyncResultWaiter()
        self.assertFalse(waiter.async_res.ready())
        token = waiter.activate()
        self.assertFalse(waiter.async_res.ready())
        log.info("Wait token: %s", token)

        pub = Publisher(to_name=token)
        async_msg = AsyncResultMsg(request_id=request_id)
        pub.publish(async_msg)

        res = waiter.await(timeout=1, request_id=request_id)
        self.assertTrue(waiter.async_res.ready())
        self.assertIsInstance(res, AsyncResultMsg)
        self.assertEqual(res.__dict__, async_msg.__dict__)
Exemplo n.º 2
0
 def start_rel_blocking(self, rel_def, timeout=None):
     waiter = AsyncResultWaiter()
     reply_to = waiter.activate()
     command_id = self.start_rel(rel_def, reply_to)
     cmd_res = waiter.await(timeout=timeout, request_id=command_id)   # This could take a long time!
     return cmd_res