0
点赞
收藏
分享

微信扫一扫

grpc

菜菜捞捞 2022-06-01 阅读 39

起多个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)

 

举报

相关推荐

0 条评论