Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/twisted_8_1/twisted/names/resolve.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4
5 """
6 Lookup a name using multiple resolvers.
7
8 Future Plans: This needs someway to specify which resolver answered
9 the query, or someway to specify (authority|ttl|cache behavior|more?)
10
11 @author: U{Jp Calderone<mailto:exarkun@twistedmatrix.com>}
12 """
13
14 from twisted.internet import defer, interfaces
15 from twisted.names import dns
16 from zope.interface import implements
17 import common
18
19 class FailureHandler:
20 def __init__(self, resolver, query, timeout):
21 self.resolver = resolver
22 self.query = query
23 self.timeout = timeout
24
25
26 def __call__(self, failure):
27 # AuthoritativeDomainErrors should halt resolution attempts
28 failure.trap(dns.DomainError, defer.TimeoutError, NotImplementedError)
29 return self.resolver(self.query, self.timeout)
30
31
32 class ResolverChain(common.ResolverBase):
33 """Lookup an address using multiple C{IResolver}s"""
34
35 implements(interfaces.IResolver)
36
37
38 def __init__(self, resolvers):
39 common.ResolverBase.__init__(self)
40 self.resolvers = resolvers
41
42
43 def _lookup(self, name, cls, type, timeout):
44 q = dns.Query(name, type, cls)
45 d = self.resolvers[0].query(q, timeout)
46 for r in self.resolvers[1:]:
47 d = d.addErrback(
48 FailureHandler(r.query, q, timeout)
49 )
50 return d
51
52
53 def lookupAllRecords(self, name, timeout = None):
54 d = self.resolvers[0].lookupAllRecords(name, timeout)
55 for r in self.resolvers[1:]:
56 d = d.addErrback(
57 FailureHandler(r.lookupAllRecords, name, timeout)
58 )
59 return d
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/names/hosts.py ('k') | third_party/twisted_8_1/twisted/names/root.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698