예제 #1
0
 def test_wait_for_deferred_requests__abandon(self):
     with async_server_context(FooService(), interval_to_keep_result=0.1,
                               result_garbage_collector_interval=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())
         self.assertTrue(server.wait_for_empty_deferred_requests(0.4))
예제 #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())
예제 #3
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()
예제 #4
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())
예제 #5
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()
예제 #6
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())
예제 #7
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())
예제 #8
0
def create_client():
    return Client(ZeroRPCClientTransport.create_tcp(8192))
예제 #9
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())
예제 #10
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())