jina.serve.runtimes.worker package

Module contents

class jina.serve.runtimes.worker.WorkerRuntime(args, cancel_event=None, \*kwargs*)[source]

Bases: jina.serve.runtimes.asyncio.AsyncNewLoopRuntime, abc.ABC

Runtime procedure leveraging Grpclet for sending DataRequests

Initialize grpc and data request handling. :type args: Namespace :param args: args from CLI :type cancel_event: Union[Event, Event, Event, None] :param cancel_event: the cancel event used to wait for canceling :param kwargs: keyword args

  • async async_setup()[source]

    Wait for the GRPC server to start

  • async async_run_forever()[source]

    Block until the GRPC server is terminated

  • async async_cancel()[source]

    Stop the GRPC server

  • async async_teardown()[source]

    Close the data request handler

  • async process_single_data(request, context)[source]

    Process the received requests and return the result as a new request

    • Parameters

      • request (DataRequest) – the data request to process

      • context – grpc context

      Return type

      DataRequest

      Returns

      the response request

  • async process_data(requests, context)[source]

    Process the received requests and return the result as a new request

    • Parameters

      • requests (List[DataRequest]) – the data requests to process

      • context – grpc context

      Return type

      DataRequest

      Returns

      the response request

  • async process_control(request, \args*)[source]

    Process the received control request and return the same request

    • Parameters

      • request (ControlRequest) – the control request to process

      • args – additional arguments in the grpc call, ignored

      Return type

      ControlRequest

      Returns

      the input request