jina.serve.runtimes.head package#
Module contents#
- class jina.serve.runtimes.head.HeadRuntime(args, **kwargs)[source]#
Bases:
AsyncNewLoopRuntime
,ABC
Runtime is used in head pods. It responds to Gateway requests and sends to uses_before/uses_after and its workers
Initialize grpc server for the head runtime. :type args:
Namespace
:param args: args from CLI :param kwargs: keyword args- DEFAULT_POLLING = 1#
- 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 processcontext – grpc context
- Return type:
- Returns:
the response request
- async process_data(requests, context)[source]#
Process the received data request and return the result as a new request
- Parameters:
requests (
List
[DataRequest
]) – the data requests to processcontext – grpc context
- Return type:
- Returns:
the response request
- async endpoint_discovery(empty, context)[source]#
Uses the connection pool to send a discover endpoint call to the workers
- Parameters:
empty – The service expects an empty protobuf message
context – grpc context
- Return type:
EndpointsProto
- Returns:
the response request
- static activate(**kwargs)#
Activate the runtime, does not apply to these runtimes
- Parameters:
kwargs – extra keyword arguments
- static is_ready(ctrl_address, **kwargs)#
Check if status is ready.
- Parameters:
ctrl_address (
str
) – the address where the control request needs to be sentkwargs – 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.
- static 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 determinedctrl_address (
str
) – the address where the control message needs to be sentready_or_shutdown_event (
Union
[Event
,Event
]) – the multiprocessing event to detect if the process failed or is readykwargs – extra keyword arguments
- Returns:
True if is ready or it needs to be shutdown