jina.serve.runtimes.worker package#

Submodules#

Module contents#

class jina.serve.runtimes.worker.WorkerRuntime(args, **kwargs)[source]#

Bases: AsyncNewLoopRuntime, ABC

Runtime procedure leveraging Grpclet for sending DataRequests

Initialize grpc and data request handling. :type args: Namespace :param args: args from CLI :param kwargs: keyword args

async async_setup()[source]#

Start the WorkerRequestHandler and wait for the GRPC and Monitoring servers 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 endpoint_discovery(empty, context)[source]#

Process the the call requested and return the list of Endpoints exposed by the Executor wrapped inside this Runtime

Parameters:
  • empty – The service expects an empty protobuf message

  • context – grpc context

Return type:

EndpointsProto

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 Check(request, context)[source]#

Calls the underlying HealthServicer.Check method with the same arguments :type request: HealthCheckRequest :param request: grpc request :param context: grpc request context :rtype: HealthCheckResponse :returns: the grpc HealthCheckResponse

async Watch(request, context)[source]#

Calls the underlying HealthServicer.Watch method with the same arguments :type request: HealthCheckRequest :param request: grpc request :param context: grpc request context :rtype: HealthCheckResponse :returns: the grpc HealthCheckResponse

aio_tracing_client_interceptors()#

Create a gRPC client aio channel interceptor. :rtype: Optional[Sequence[ClientInterceptor]] :returns: An invocation-side list of aio interceptor objects.

aio_tracing_server_interceptors()#

Create a gRPC aio server interceptor. :rtype: Optional[Sequence[ServerInterceptor]] :returns: A service-side aio interceptor object.

async cancel_warmup_task()#

Cancel warmup task if exists and is not completed. Cancellation is required if the Flow is being terminated before the task is successful or hasn’t reached the max timeout.

static is_ready(ctrl_address, timeout=1.0, **kwargs)#

Check if status is ready.

Parameters:
  • ctrl_address (str) – the address where the control request needs to be sent

  • timeout (float) – timeout of the health check in seconds

  • kwargs – extra keyword arguments

Return type:

bool

Returns:

True if status is ready else False.

run_forever()#

Running method to block the main thread.

Run the event loop until a Future is done.

teardown()#

Call async_teardown() and stop and close the event loop.

tracing_client_interceptor()#
Return type:

Optional[OpenTelemetryClientInterceptor]

Returns:

a gRPC client interceptor with the global tracing provider.

classmethod wait_for_ready_or_shutdown(timeout, ready_or_shutdown_event, ctrl_address, **kwargs)#

Check if the runtime has successfully started

Parameters:
  • timeout (Optional[float]) – The time to wait before readiness or failure is determined

  • ctrl_address (str) – the address where the control message needs to be sent

  • ready_or_shutdown_event (Union[Event, Event]) – the multiprocessing event to detect if the process failed or is ready

  • kwargs – extra keyword arguments

Returns:

True if is ready or it needs to be shutdown