class_docstr: A future-like object wrapping the result of a streaming deployment handle call.
  
  This is returned when using `handle.options(stream=True)` and calling a generator
  deployment method.
  
  `DeploymentResponseGenerator` is both a synchronous and asynchronous iterator.
  
  When iterating over results from inside a deployment, `async for` should be used to
  avoid blocking the asyncio event loop.
  
  When iterating over results from outside a deployment, use a standard `for` loop.
  
  Example:
  
  .. code-block:: python
  
      from typing import AsyncGenerator, Generator
  
      from ray import serve
      from ray.serve.handle import DeploymentHandle
  
      @serve.deployment
      class Streamer:
          def generate_numbers(self, limit: int) -> Generator[int]:
              for i in range(limit):
                  yield i
  
      @serve.deployment
      class Caller:
          def __init__(self, handle: DeploymentHandle):
              # Set `stream=True` on the handle to enable streaming calls.
              self._streaming_handle = handle.options(stream=True)
  
      async def __call__(self, limit: int) -> AsyncIterator[int]:
          gen: DeploymentResponseGenerator = (
              self._streaming_handle.generate_numbers.remote(limit)
          )
  
          # Inside a deployment: use `async for` to enable concurrency.
          async for i in gen:
              yield i
  
      app = Caller.bind(Streamer.bind())
      handle: DeploymentHandle = serve.run(app)
  
      # Outside a deployment: use a standard `for` loop.
      gen: DeploymentResponseGenerator = handle.options(stream=True).remote(10)
      assert [i for i in gen] == list(range(10))
  
  A `DeploymentResponseGenerator` *cannot* currently be passed to another
  `DeploymentHandle` call.
class_docstr_tok: ["A","future-like","object","wrapping","the","result","of","a","streaming","deployment","handle","call",".","This","is","returned","when","using","`","handle.options","(","stream=True",")","`","and","calling","a","generator","deployment","method",".","`","DeploymentResponseGenerator","`","is","both","a","synchronous","and","asynchronous","iterator",".","When","iterating","over","results","from","inside","a","deployment",",","`","async","for","`","should","be","used","to","avoid","blocking","the","asyncio","event","loop",".","When","iterating","over","results","from","outside","a","deployment",",","use","a","standard","`","for","`","loop",".","Example",":","..","code-block",":",":","python","from","typing","import","AsyncGenerator",",","Generator","from","ray","import","serve","from","ray.serve.handle","import","DeploymentHandle","@","serve.deployment","class","Streamer",":","def","generate_numbers","(","self",",","limit",":","int",")","-",">","Generator","[","int","]",":","for","i","in","range","(","limit",")",":","yield","i","@","serve.deployment","class","Caller",":","def","__init__","(","self",",","handle",":","DeploymentHandle",")",":","#","Set","`","stream=True","`","on","the","handle","to","enable","streaming","calls",".","self._streaming_handle","=","handle.options","(","stream=True",")","async","def","__call__","(","self",",","limit",":","int",")","-",">","AsyncIterator","[","int","]",":","gen",":","DeploymentResponseGenerator","=","(","self._streaming_handle.generate_numbers.remote","(","limit",")",")","#","Inside","a","deployment",":","use","`","async","for","`","to","enable","concurrency",".","async","for","i","in","gen",":","yield","i","app","=","Caller.bind","(","Streamer.bind","(",")",")","handle",":","DeploymentHandle","=","serve.run","(","app",")","#","Outside","a","deployment",":","use","a","standard","`","for","`","loop",".","gen",":","DeploymentResponseGenerator","=","handle.options","(","stream=True",")",".remote","(","10",")","assert","[","i","for","i","in","gen","]","==","list","(","range","(","10",")",")","A","`","DeploymentResponseGenerator","`","*","can","not","*","currently","be","passed","to","another","`","DeploymentHandle","`","call","."]
code: def __next__(self) -> Any:
      if self._obj_ref_gen is None:
          self._obj_ref_gen = self._to_object_ref_gen_sync(
              _record_telemetry=False
          )
  
      next_obj_ref = self._obj_ref_gen.__next__()
      return ray.get(next_obj_ref)
  
imports: import asyncio
  import concurrent.futures
  import threading
  import warnings
  from dataclasses import dataclass
  from typing import Any, AsyncIterator, Dict, Iterator, Optional, Tuple, Union
  import ray
  from ray import serve
  from ray._raylet import GcsClient, ObjectRefGenerator
  from ray.serve._private.common import DeploymentID, RequestProtocol
  from ray.serve._private.default_impl import create_cluster_node_info_cache
  from ray.serve._private.router import RequestMetadata, Router
  from ray.serve._private.usage import ServeUsageTag
  from ray.serve._private.utils import DEFAULT, get_current_actor_id, get_random_string, is_running_in_asyncio_loop
  from ray.util import metrics
  from ray.util.annotations import Deprecated, DeveloperAPI, PublicAPI
label_desc: Use image node_id 5 for calling the DeploymentResponseGenerator obj's underlying member method code with example usage: obj.__next__() and returns: ray