class_docstr: Twisted-based asynchronous resolver.
  
  This is a non-blocking and non-threaded resolver.  It is
  recommended only when threads cannot be used, since it has
  limitations compared to the standard ``getaddrinfo``-based
  `~tornado.netutil.Resolver` and
  `~tornado.netutil.DefaultExecutorResolver`.  Specifically, it returns at
  most one result, and arguments other than ``host`` and ``family``
  are ignored.  It may fail to resolve when ``family`` is not
  ``socket.AF_UNSPEC``.
  
  Requires Twisted 12.1 or newer.
  
  .. versionchanged:: 5.0
     The ``io_loop`` argument (deprecated since version 4.1) has been removed.
  
  .. deprecated:: 6.2
     This class is deprecated and will be removed in Tornado 7.0. Use the default
     thread-based resolver instead.
class_docstr_tok: ["Twisted-based","asynchronous","resolver",".","This","is","a","non-blocking","and","non-threaded","resolver",".","It","is","recommended","only","when","threads","can","not","be","used",",","since","it","has","limitations","compared","to","the","standard","``","getaddrinfo","``","-based","`","~tornado.netutil.Resolver","`","and","`","~tornado.netutil.DefaultExecutorResolver","`",".","Specifically",",","it","returns","at","most","one","result",",","and","arguments","other","than","``","host","``","and","``","family","``","are","ignored",".","It","may","fail","to","resolve","when","``","family","``","is","not","``","socket.AF_UNSPEC","``",".","Requires","Twisted","12.1","or","newer",".","..","versionchanged",":",":","5.0","The","``","io_loop","``","argument","(","deprecated","since","version","4.1",")","has","been","removed",".","..","deprecated",":",":","6.2","This","class","is","deprecated","and","will","be","removed","in","Tornado","7.0",".","Use","the","default","thread-based","resolver","instead","."]
code: def resolve(
      self, host: str, port: int, family: int = 0
  ) -> "Generator[Any, Any, List[Tuple[int, Any]]]":
      # getHostByName doesn't accept IP addresses, so if the input
      # looks like an IP address just return it immediately.
      if twisted.internet.abstract.isIPAddress(host):
          resolved = host
          resolved_family = socket.AF_INET
      elif twisted.internet.abstract.isIPv6Address(host):
          resolved = host
          resolved_family = socket.AF_INET6
      else:
          deferred = self.resolver.getHostByName(utf8(host))
          fut = Future()  # type: Future[Any]
          deferred.addBoth(fut.set_result)
          resolved = yield fut
          if isinstance(resolved, failure.Failure):
              try:
                  resolved.raiseException()
              except twisted.names.error.DomainError as e:
                  raise IOError(e)
          elif twisted.internet.abstract.isIPAddress(resolved):
              resolved_family = socket.AF_INET
          elif twisted.internet.abstract.isIPv6Address(resolved):
              resolved_family = socket.AF_INET6
          else:
              resolved_family = socket.AF_UNSPEC
      if family != socket.AF_UNSPEC and family != resolved_family:
          raise Exception(
              "Requested socket family %d but got %d"
              % (family, resolved_family)
          )
      result = [(typing.cast(int, resolved_family), (resolved, port))]
      return result
  
file_path: catboost/contrib/python/tornado/tornado-6/tornado/platform/twisted.py
imports: import socket
  import sys
  import twisted.internet.abstract
  import twisted.internet.asyncioreactor
  from twisted.internet.defer import Deferred
  from twisted.python import failure
  import twisted.names.cache
  import twisted.names.client
  import twisted.names.hosts
  import twisted.names.resolve
  from tornado.concurrent import Future, future_set_exc_info
  from tornado.escape import utf8
  from tornado import gen
  from tornado.netutil import Resolver
  import typing
label_desc: Use image node_id 2 for calling the TwistedResolver obj's underlying member method code with example usage: obj.resolve(host, port, family) and returns: result