def main(): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) servicer = PiCalculatorServicer() pi_pb2_grpc.add_PiCalculatorServicer_to_server(servicer, server) server.add_insecure_port('localhost:8080') server.start() try: time.sleep(1000) except KeyboardInterrupt: server.stop(0)
def main(): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) servicer = PiCalculatorServicer() pi_pb2_grpc.add_PiCalculatorServicer_to_server(servicer, server) server.add_insecure_port('localhost:8080') server.start() try: time.sleep(1000) except KeyboardInterrupt: server.stop(0)
def main(): # 多线程服务器 server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) # 实例化圆周率服务类 servicer = PiCalculatorServicer() # 注册本地服务 pi_pb2_grpc.add_PiCalculatorServicer_to_server(servicer, server) # 监听端口 server.add_insecure_port('127.0.0.1:8080') # 开始接收请求进行服务 server.start() # 使用 ctrl+c 可以退出服务 try: time.sleep(1000) except KeyboardInterrupt: server.stop(0)
def main(addr): # 多线程服务 server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) # 实例化圆周率服务类 servicer = PiCalculatorServicer() # 注册本地服务 pi_pb2_grpc.add_PiCalculatorServicer_to_server(servicer, server) # 监听端口 server.add_insecure_port(addr) # 开始接收请求进行服务 server.start() # 使用ctrl + c 可以退出服务 try: time.sleep(1000) except KeyboardInterrupt: server.stop(0)
def main(): # 多线程服务器 server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) # 实例化圆周率服务类 servicer = PiCalculatorServicer() # 注册本地服务 pi_pb2_grpc.add_PiCalculatorServicer_to_server(servicer, server) # 监听端口 server.add_insecure_port('127.0.0.1:8080') # 开始接收请求进行服务 server.start() # 使用 ctrl+c 可以退出服务 # try: # time.sleep(1000) # except KeyboardInterrupt: # server.stop(0) # below will not stop except ctrl+c while True: try: pass except KeyboardInterrupt: server.stop(0)