grpc

起多个grpc server:

def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=settings.workers))

    ########## add new service
    capacity_pb2_grpc.add_capacityServicer_to_server(cap_calculate(),server)
    statistic_pb2_grpc.add_statisticServicer_to_server(Statistic(), server)
    device_status_monit_pb2_grpc.add_MonitDeviceServicer_to_server(MonitDevice(), server)
    server.add_insecure_port(settings.listen_info)
    server.start()
    print "start success"
    try:
        while True:
            time.sleep(settings.sleep_time)
    except KeyboardInterrupt:
          server.stop(0)
原文地址:https://www.cnblogs.com/testzcy/p/11187902.html