class_docstr: Asynchronous client.
class_docstr_tok: ["Asynchronous","client","."]
docstr: Build a future handler for a given method.
docstr_tok: ["Build","a","future","handler","for","a","given","method","."]
code: def _build_handler(self, method: str):
      """Build a future handler for a given method."""
  
      def call(*args, **kwargs):
          f = futures.Future()
  
          def set_exception(s):
              try:
                  f.set_exception(translate_status(s))
              except (
                  futures.InvalidStateError
              ):  # pytype: disable=module-attr
                  # Call could have been already canceled by the user.
                  pass
  
          def set_result(r):
              try:
                  f.set_result(r)
              except futures.InvalidStateError:
                  # Call could have been already canceled by the user.
                  pass
  
          deadline = _calculate_deadline(
              self._call_timeout, self._propagate_deadline
          )
  
          canceller = self._client.AsyncPyCall(
              method,
              list(args),
              kwargs,
              set_result,
              set_exception,
              self._wait_for_ready,
              deadline,
              self._compress,
              self._chunk_tensors,
          )
  
          def done_callback(f):
              if f.cancelled():
                  canceller.Cancel()
  
          f.add_done_callback(done_callback)
          return f
  
      return call
  
imports: from concurrent import futures
  import datetime
  from typing import List, Optional, Union
  import zoneinfo
  from courier.python import py_client
  import numpy
  from pybind11_abseil.status import StatusNotOk
  from pybind11_abseil.status import StatusNotOk
label_desc: Use image node_id 2 for calling the _AsyncClient obj's underlying member method code with example usage: obj._build_handler(method) and returns: call, f