Exemple #1
0
    def test_06_blocking_methods(self):
        future = Future(self.f.future_create(ffi.NULL, ffi.NULL))

        self.assertFalse(future.is_ready())
        with self.assertRaises(EnvironmentError) as cm:
            future.wait_for(timeout=0)
        self.assertEqual(cm.exception.errno, errno.ETIMEDOUT)

        future.pimpl.fulfill(ffi.NULL, ffi.NULL)
        self.assertTrue(future.is_ready())
        try:
            future.wait_for(0)
        except EnvironmentError as e:
            self.fail("future.wait_for raised an unexpected exception: {}".format(e))
Exemple #2
0
    def test_08_future_from_future(self):
        orig_fut = Future(self.f.future_create(ffi.NULL, ffi.NULL))
        new_fut = Future(orig_fut)
        self.assertFalse(new_fut.is_ready())
        orig_fut.pimpl.fulfill(ffi.NULL, ffi.NULL)
        self.assertTrue(new_fut.is_ready())

        orig_fut = self.f.rpc("broker.ping", payload=self.ping_payload)
        new_fut = Future(orig_fut)
        del orig_fut
        resp_payload = new_fut.get()
        # Future's `get` returns `None`, so just test that it is fulfilled
        self.assertTrue(new_fut.is_ready())

        orig_fut = self.f.rpc("foo.bar")
        new_fut = Future(orig_fut)
        del orig_fut
        with self.assertRaises(EnvironmentError):
            resp_payload = new_fut.get()