Example #1
0
 def test_wait_for_deferred_requests__abort(self):
     with async_server_context(FooService(),
                               interval_to_keep_result=5) as server:
         client_transport = ZeroRPCClientTransport.create_tcp(8192)
         client = Client(client_transport)
         client.bar(async_rpc=True)
         self.assertTrue(server.has_deferred_requests())
         self.assertFalse(server.wait_for_empty_deferred_requests(0.1))
         server.garbage_collect_deferred_results()
Example #2
0
 def test_abandon_deferred_requests(self):
     with async_server_context(FooService(),
                               interval_to_keep_result=0.1) as server:
         client_transport = ZeroRPCClientTransport.create_tcp(8192)
         client = Client(client_transport)
         client.bar(async_rpc=True)
         self.assertTrue(server.has_deferred_requests())
         gevent.sleep(0.2)
         server.garbage_collect_deferred_results()
         self.assertFalse(server.has_deferred_requests())
Example #3
0
    def test_straightforward(self):
        try:
            server_transport = ZeroRPCServerTransport.create_tcp(8192)
            server = SyncServer(transport=server_transport, service=FooService())
            server.bind()

            client_transport = ZeroRPCClientTransport.create_tcp(8192)
            client = Client(client_transport)
            self.assertEqual(client.foo(), 42)
        finally:
            server.unbind()
Example #4
0
 def test_wait_for_deferred_requests__finish(self):
     with async_server_context(FooService(),
                               interval_to_keep_result=5) as server:
         client_transport = ZeroRPCClientTransport.create_tcp(8192)
         client = Client(client_transport)
         deferred = client.bar(async_rpc=True)
         self.assertTrue(server.has_deferred_requests())
         g = gevent.spawn(deferred.get_result)
         server.wait_for_empty_deferred_requests()
         self.assertEqual(24, g.get())
         server.garbage_collect_deferred_results()
         self.assertFalse(server.has_deferred_requests())
Example #5
0
def create_client():
    return Client(ZeroRPCClientTransport.create_tcp(8192))
Example #6
0
 def test_straightforward(self):
     with async_server_context(FooService()) as server:
         client_transport = ZeroRPCClientTransport.create_tcp(8192)
         client = Client(client_transport)
         self.assertEqual(client.foo(), 42)
         self.assertFalse(server.has_deferred_requests())