Esempio n. 1
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
    classification_pb2_grpc.add_ClassificationServicer_to_server(
        Classificator(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)
Esempio n. 2
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
    classification_pb2_grpc.add_ClassificationServicer_to_server(
        Classificator(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    try:
        callback_command = sys.argv[1]
        subprocess.call(callback_command, shell=True)
    except:
        pass
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)
Esempio n. 3
0
def serve(host, port, model):
    '''
    Start gRPC Classification Server
    '''
    # Create Server
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    # Attach gRPC Servicer to Server
    ClassificationServer.add_ClassificationServicer_to_server(Classification(model), server)
    
    # Start Server
    logging.info('Starting Server')
    server.add_insecure_port('{}:{}'.format(host, port))
    server.start()
    logging.info('Server Listening on %s:%d', host, port)

    try:
        while True:
            time.sleep(60*60*24)
    except KeyboardInterrupt:
        server.stop(0)