示例#1
0
    def test_expose_before_init(self, pymq_init):
        def remote_fn():
            return "hello"

        pymq.expose(remote_fn, "remote_fn")

        with pytest.raises(ValueError):
            stub = pymq.stub("remote_fn")
            stub()

        pymq_init()

        stub = pymq.stub("remote_fn")
        assert "hello" == stub()
示例#2
0
    def test_channel_expire(self, pymq_redis, redislite):
        bus = pymq_redis.core._bus
        bus.rpc_channel_expire = 1
        called = threading.Event()

        def remotefn():
            time.sleep(1.25)
            called.set()

        pymq.expose(remotefn)

        stub = pymq.stub(remotefn, timeout=1)
        stub.rpc()
        keys = redislite.keys("*rpc*")
        assert 0 == len(keys), "Expected no rpc results yet %s" % keys

        called.wait()

        keys = redislite.keys("*rpc*")
        assert 1 == len(keys)

        # wait for key to expire
        time.sleep(1.25)

        keys = redislite.keys("*rpc*")
        assert 0 == len(keys), "key did not expire"
示例#3
0
 def info(self) -> List[ClientInfo]:
     return pymq.stub('Client.get_info', timeout=2, multi=True)()
示例#4
0
文件: test_pymq.py 项目: thrau/pymq
    def test_stub_on_non_started_bus(self):
        def fn():
            pass

        with pytest.raises(ValueError):
            pymq.stub(fn)