def __call__(self, request, timeout=None, metadata=None, credentials=None, *, standalone_pool=None): """Invokes the underlying RPC. Args: request: The request value for the RPC. timeout: An optional duration of time in seconds to allow for the RPC. If None, the timeout is considered infinite. metadata: An optional :term:`metadata` to be transmitted to the service-side of the RPC. credentials: An optional CallCredentials for the RPC. Returns: An object that is both a Call for the RPC and an ASYNC iterator of response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status. """ if standalone_pool is None: standalone_pool = self._standalone_pool if standalone_pool: stream_executor = _ThreadPoolExecutor(1) else: stream_executor = None return _utils.WrappedIterator( self._inner(request, timeout, metadata, credentials), self._loop, self._executor, stream_executor)
def __call__(self, request_iterator, timeout=None, metadata=None, credentials=None, *, standalone_pool = None): """Invokes the underlying RPC on the client. Args: request_iterator: An iterator that yields request values for the RPC. timeout: An optional duration of time in seconds to allow for the RPC. if not specified the timeout is considered infinite. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. credentials: An optional CallCredentials for the RPC. Returns: An object that is both a Call for the RPC and an iterator of response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status. """ if standalone_pool is None: standalone_pool = self._standalone_pool if standalone_pool: stream_executor = _ThreadPoolExecutor(1) else: stream_executor = None input_iterator = _utils.WrappedAsyncIterator(request_iterator, self._loop) grpc_iterator = self._inner( input_iterator, timeout, metadata, credentials ) r = _utils.WrappedIterator( grpc_iterator, self._loop, self._executor, stream_executor) # Make sure the input iterator exits, or the thread may block indefinitely def _end_callback(): input_iterator.cancel(False) grpc_iterator.add_callback(_end_callback) return r