jina.serve.stream package

Submodules

Module contents

class jina.serve.stream.RequestStreamer(args, request_handler, result_handler, end_of_iter_handler=None, logger=None)[source]

Bases: object

A base async request/response streamer.

Parameters
  • args (Namespace) – args from CLI

  • request_handler (Callable[[ForwardRef], ForwardRef]) – The callable responsible for handling the request. It should handle a request as input and return a Future to be awaited

  • result_handler (Callable[[ForwardRef], Optional[ForwardRef]]) – The callable responsible for handling the response.

  • end_of_iter_handler (Optional[Callable[[], None]]) – Optional callable to handle the end of iteration if some special action needs to be taken.

  • logger (Optional[ForwardRef]) – Optional logger that can be used for logging

async stream(request_iterator, context=None, *args)[source]

stream requests from client iterator and stream responses back.

Parameters
  • request_iterator – iterator of requests

  • context – context of the grpc call

  • args – positional arguments

Yield

responses from Executors

Return type

AsyncIterator[ForwardRef]