MCPcopy Create free account
hub / github.com/EasyIME/PIME / Resolver

Class Resolver

python/python3/tornado/netutil.py:314–383  ·  view source on GitHub ↗

Configurable asynchronous DNS resolver interface. By default, a blocking implementation is used (which simply calls `socket.getaddrinfo`). An alternative implementation can be chosen with the `Resolver.configure <.Configurable.configure>` class method:: Resolver.configure(

Source from the content-addressed store, hash-verified

312
313
314class Resolver(Configurable):
315 """Configurable asynchronous DNS resolver interface.
316
317 By default, a blocking implementation is used (which simply calls
318 `socket.getaddrinfo`). An alternative implementation can be
319 chosen with the `Resolver.configure <.Configurable.configure>`
320 class method::
321
322 Resolver.configure('tornado.netutil.ThreadedResolver')
323
324 The implementations of this interface included with Tornado are
325
326 * `tornado.netutil.DefaultLoopResolver`
327 * `tornado.netutil.DefaultExecutorResolver` (deprecated)
328 * `tornado.netutil.BlockingResolver` (deprecated)
329 * `tornado.netutil.ThreadedResolver` (deprecated)
330 * `tornado.netutil.OverrideResolver`
331 * `tornado.platform.twisted.TwistedResolver` (deprecated)
332 * `tornado.platform.caresresolver.CaresResolver` (deprecated)
333
334 .. versionchanged:: 5.0
335 The default implementation has changed from `BlockingResolver` to
336 `DefaultExecutorResolver`.
337
338 .. versionchanged:: 6.2
339 The default implementation has changed from `DefaultExecutorResolver` to
340 `DefaultLoopResolver`.
341 """
342
343 @classmethod
344 def configurable_base(cls) -> Type["Resolver"]:
345 return Resolver
346
347 @classmethod
348 def configurable_default(cls) -> Type["Resolver"]:
349 return DefaultLoopResolver
350
351 def resolve(
352 self, host: str, port: int, family: socket.AddressFamily = socket.AF_UNSPEC
353 ) -> Awaitable[List[Tuple[int, Any]]]:
354 """Resolves an address.
355
356 The ``host`` argument is a string which may be a hostname or a
357 literal IP address.
358
359 Returns a `.Future` whose result is a list of (family,
360 address) pairs, where address is a tuple suitable to pass to
361 `socket.connect <socket.socket.connect>` (i.e. a ``(host,
362 port)`` pair for IPv4; additional fields may be present for
363 IPv6). If a ``callback`` is passed, it will be run with the
364 result as an argument when it is complete.
365
366 :raises IOError: if the address cannot be resolved.
367
368 .. versionchanged:: 4.4
369 Standardized all implementations to raise `IOError`.
370
371 .. versionchanged:: 6.0 The ``callback`` argument was removed.

Callers 3

__init__Method · 0.90
initializeMethod · 0.90
skipIfLocalhostV4Method · 0.90

Calls

no outgoing calls

Tested by 1

skipIfLocalhostV4Method · 0.72