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)

 

posted on 2019-07-15 11:34  我和你并没有不同  阅读(329)  评论(0编辑  收藏  举报