class_docstr: A handle used to make requests to a deployment at runtime.
  
  This is primarily used to compose multiple deployments within a single application.
  It can also be used to make calls to the ingress deployment of an application (e.g.,
  for programmatic testing).
  
  Example:
  
  
  .. code-block:: python
  
      import ray
      from ray import serve
      from ray.serve.handle import DeploymentHandle, DeploymentResponse
  
      @serve.deployment
      class Downstream:
          def say_hi(self, message: str):
              return f"Hello {message}!"
              self._message = message
  
      @serve.deployment
      class Ingress:
          def __init__(self, handle: DeploymentHandle):
              self._downstream_handle = handle
  
          async def __call__(self, name: str) -> str:
              response = self._handle.say_hi.remote(name)
              return await response
  
      app = Ingress.bind(Downstream.bind())
      handle: DeploymentHandle = serve.run(app)
      response = handle.remote("world")
      assert response.result() == "Hello world!"
class_docstr_tok: ["A","handle","used","to","make","requests","to","a","deployment","at","runtime",".","This","is","primarily","used","to","compose","multiple","deployments","within","a","single","application",".","It","can","also","be","used","to","make","calls","to","the","ingress","deployment","of","an","application","(","e.g.",",","for","programmatic","testing",")",".","Example",":","..","code-block",":",":","python","import","ray","from","ray","import","serve","from","ray.serve.handle","import","DeploymentHandle",",","DeploymentResponse","@","serve.deployment","class","Downstream",":","def","say_hi","(","self",",","message",":","str",")",":","return","f","''","Hello","{","message","}","!","''","self._message","=","message","@","serve.deployment","class","Ingress",":","def","__init__","(","self",",","handle",":","DeploymentHandle",")",":","self._downstream_handle","=","handle","async","def","__call__","(","self",",","name",":","str",")","-",">","str",":","response","=","self._handle.say_hi.remote","(","name",")","return","await","response","app","=","Ingress.bind","(","Downstream.bind","(",")",")","handle",":","DeploymentHandle","=","serve.run","(","app",")","response","=","handle.remote","(","``","world","''",")","assert","response.result","(",")","==","``","Hello","world","!","''"]
docstr: Issue a remote call to a method of the deployment.
  
  By default, the result is a `DeploymentResponse` that can be awaited to fetch
  the result of the call or passed to another `.remote()` call to compose multiple
  deployments.
  
  If `handle.options(stream=True)` is set and a generator method is called, this
  returns a `DeploymentResponseGenerator` instead.
  
  Example:
  
  .. code-block:: python
  
      # Fetch the result directly.
      response = handle.remote()
      result = await response
  
      # Pass the result to another handle call.
      composed_response = handle2.remote(handle1.remote())
      composed_result = await composed_response
  
  Args:
      *args: Positional arguments to be serialized and passed to the
          remote method call.
      **kwargs: Keyword arguments to be serialized and passed to the
          remote method call.
docstr_tok: ["Issue","a","remote","call","to","a","method","of","the","deployment",".","By","default",",","the","result","is","a","`","DeploymentResponse","`","that","can","be","awaited","to","fetch","the","result","of","the","call","or","passed","to","another","`",".remote","(",")","`","call","to","compose","multiple","deployments",".","If","`","handle.options","(","stream=True",")","`","is","set","and","a","generator","method","is","called",",","this","returns","a","`","DeploymentResponseGenerator","`","instead",".","Example",":","..","code-block",":",":","python","#","Fetch","the","result","directly",".","response","=","handle.remote","(",")","result","=","await","response","#","Pass","the","result","to","another","handle","call",".","composed_response","=","handle2.remote","(","handle1.remote","(",")",")","composed_result","=","await","composed_response","Args",":","*","args",":","Positional","arguments","to","be","serialized","and","passed","to","the","remote","method","call",".","*","*","kwargs",":","Keyword","arguments","to","be","serialized","and","passed","to","the","remote","method","call","."]
code: def remote(
      self, *args, **kwargs
  ) -> Union[DeploymentResponse, DeploymentResponseGenerator]:
      """Issue a remote call to a method of the deployment.
  
      By default, the result is a `DeploymentResponse` that can be awaited to fetch
      the result of the call or passed to another `.remote()` call to compose multiple
      deployments.
  
      If `handle.options(stream=True)` is set and a generator method is called, this
      returns a `DeploymentResponseGenerator` instead.
  
      Example:
  
      .. code-block:: python
  
          # Fetch the result directly.
          response = handle.remote()
          result = await response
  
          # Pass the result to another handle call.
          composed_response = handle2.remote(handle1.remote())
          composed_result = await composed_response
  
      Args:
          *args: Positional arguments to be serialized and passed to the
              remote method call.
          **kwargs: Keyword arguments to be serialized and passed to the
              remote method call.
      """
      future = self._remote(args, kwargs)
      if self.handle_options.stream:
          response_cls = DeploymentResponseGenerator
      else:
          response_cls = DeploymentResponse
  
      return response_cls(future)
  
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 2 for calling the DeploymentHandle obj's underlying member method code with example usage: obj.remote() and returns: response_cls