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

  • 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)


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”


next request or None