docstr: Attempt to cancel the `DeploymentHandle` call.
  
  This is best effort.
  
  - If the request hasn't been assigned to a replica actor, the assignment will be
    cancelled.
  - If the request has been assigned to a replica actor, `ray.cancel` will be
    called on the object ref, attempting to cancel the request and any downstream
    requests it makes.
  
  If the request is successfully cancelled, subsequent operations on the ref will
  raise an exception:
  
      - If the request was cancelled before assignment, they'll raise
        `asyncio.CancelledError` (or a `concurrent.futures.CancelledError` for
        synchronous methods like `.result()`.).
      - If the request was cancelled after assignment, they'll raise
        `ray.exceptions.TaskCancelledError`.
docstr_tok: ["Attempt","to","cancel","the","`","DeploymentHandle","`","call",".","This","is","best","effort",".","-","If","the","request","has","n't","been","assigned","to","a","replica","actor",",","the","assignment","will","be","cancelled",".","-","If","the","request","has","been","assigned","to","a","replica","actor",",","`","ray.cancel","`","will","be","called","on","the","object","ref",",","attempting","to","cancel","the","request","and","any","downstream","requests","it","makes",".","If","the","request","is","successfully","cancelled",",","subsequent","operations","on","the","ref","will","raise","an","exception",":","-","If","the","request","was","cancelled","before","assignment",",","they","'ll","raise","`","asyncio.CancelledError","`","(","or","a","`","concurrent.futures.CancelledError","`","for","synchronous","methods","like","`",".result","(",")","`",".",")",".","-","If","the","request","was","cancelled","after","assignment",",","they","'ll","raise","`","ray.exceptions.TaskCancelledError","`","."]
code: def cancel(self):
      """Attempt to cancel the `DeploymentHandle` call.
  
      This is best effort.
  
      - If the request hasn't been assigned to a replica actor, the assignment will be
        cancelled.
      - If the request has been assigned to a replica actor, `ray.cancel` will be
        called on the object ref, attempting to cancel the request and any downstream
        requests it makes.
  
      If the request is successfully cancelled, subsequent operations on the ref will
      raise an exception:
  
          - If the request was cancelled before assignment, they'll raise
            `asyncio.CancelledError` (or a `concurrent.futures.CancelledError` for
            synchronous methods like `.result()`.).
          - If the request was cancelled after assignment, they'll raise
            `ray.exceptions.TaskCancelledError`.
      """
      if self._cancelled:
          return
  
      self._cancelled = True
      if not self._object_ref_future.done():
          self._object_ref_future.cancel()
      elif self._object_ref_future.exception() is None:
          ray.cancel(self._object_ref_future.result())
  
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 3 for calling the _DeploymentResponseBase obj's underlying member method code with example usage: obj.cancel() without return types