peerdb/tripe-newpeers.in: Split `prepare' in twain.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 27 Sep 2017 08:40:01 +0000 (09:40 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 16 Jun 2018 18:14:10 +0000 (19:14 +0100)
There's now a front-end, still called `prepare', which establishes the
`ResolvingHost' if necessary, and a back-end, `_prepare' which actually
does the work.

You might well think that this is preparatory work for splitting out a
superclass.  I couldn't possibly comment.

peerdb/tripe-newpeers.in

index 88d3154..4476197 100644 (file)
@@ -124,15 +124,19 @@ class BulkResolver (object):
     me._namemap = {}
     me._noutstand = 0
 
+  def _prepare(me, host, name):
+    """Arrange to resolve a NAME, reporting the results to HOST."""
+    host._resolv = M.SelResolveByName(
+      name,
+      lambda cname, alias, addr: me._resolved(host, cname, addr),
+      lambda: me._resolved(host, None, []))
+    me._noutstand += 1
+
   def prepare(me, name):
     """Prime the resolver to resolve the given host NAME."""
     if name not in me._namemap:
       me._namemap[name] = host = ResolvingHost(name)
-      host._resolv = M.SelResolveByName(
-        name,
-        lambda cname, alias, addr: me._resolved(host, cname, addr),
-        lambda: me._resolved(host, None, []))
-      me._noutstand += 1
+      me._prepare(host, name)
 
   def run(me):
     """Run the background DNS resolver until it's finished."""