def test_custom_pool(self):
     """
     Tests the ability to have a custom pool
     """
     # Setup the pool
     pool = ThreadPool(2)
     pool.start()
     self.test_default_pool(pool)
Exemple #2
0
 def test_custom_pool(self):
     """
     Tests the ability to have a custom pool
     """
     # Setup the pool
     pool = ThreadPool(2)
     pool.start()
     self.test_default_pool(pool)
Exemple #3
0
 def test_sequencial(self):
     """
     Tests the behaviour with a single-thread pool
     """
     pool = ThreadPool(1, 1)
     pool.start()
     try:
         self.test_default_pool(pool, 6)
     finally:
         pool.stop()
Exemple #4
0
 def test_custom_pool(self):
     """
     Tests the ability to have a custom pool
     """
     # Setup the pool
     pool = ThreadPool(5)
     pool.start()
     try:
         self.test_default_pool(pool)
     finally:
         pool.stop()
def main():
    nofif_pool = ThreadPool(max_threads=10, min_threads=0)
    request_pool = ThreadPool(max_threads=50, min_threads=10)
    with PooledJSONRPCServer((HOST, PORT),
                             thread_pool=request_pool,
                             requestHandler=RequestHandler) as server:
        # 注册所有可调用函数的名字到system.listMethods方法
        # 注册可调用函数的docstring到system.methodHelp(func_name)方法
        # 注册可调用函数的签名到system.methodSignature(func_name)方法
        server.register_introspection_functions()
        server.set_notification_pool(nofif_pool)

        # 这个函数的作用是可以使客户端同时调用服务端的的多个函数。
        server.register_multicall_functions()
        server.register_function(md5_func, md5_func.__name__)
        try:
            nofif_pool.start()
            request_pool.start()
            log.info("server start", msg=f"jsonrpc start @ {HOST}:{PORT}!")
            server.serve_forever()
        except Exception:
            raise
        finally:
            request_pool.stop()
            nofif_pool.stop()
            server.set_notification_pool(None)
            log.info("server stoped", msg=f"jsonrpc @ {HOST}:{PORT} stoped!")