jina.serve.stream.helper module#

class jina.serve.stream.helper.AsyncRequestsIterator(iterator, request_counter=None, prefetch=0)[source]#

Bases: object

Iterator to allow async iteration of blocking/non-blocking iterator from the Client

Async request iterator

Parameters:
  • iterator (Union[Iterator, AsyncIterator]) – request iterator

  • request_counter (Optional[_RequestsCounter]) – counter of the numbers of request being handled at a given moment

  • prefetch (int) – The max amount of requests to be handled at a given moment (0 disables feature)

iterator__next__()[source]#

Executed inside a ThreadPoolExecutor via loop.run_in_executor to avoid following exception. “StopIteration interacts badly with generators and cannot be raised into a Future”

Returns:

next request or None