]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
make passing a socket to async routines actually work
authorBob Halley <halley@dnspython.org>
Wed, 17 Jun 2020 21:05:30 +0000 (14:05 -0700)
committerBob Halley <halley@dnspython.org>
Wed, 17 Jun 2020 21:05:35 +0000 (14:05 -0700)
dns/_asyncbackend.py
dns/asyncquery.py

index d96dce11d04adddcd3f2d1ae5164599b11856ed0..c7ecfada96614b213233ed42548d96e8ac1103c4 100644 (file)
@@ -28,7 +28,7 @@ class Socket:  # pragma: no cover
         pass
 
     async def __aenter__(self):
-        pass
+        return self
 
     async def __aexit__(self, exc_type, exc_value, traceback):
         await self.close()
index 709c246ab75baeccbab039b256215bf092da8f84..b36a2f640e434be26c3b85475d1804b66b34518b 100644 (file)
@@ -191,15 +191,15 @@ async def udp(q, where, timeout=None, port=53, source=None, source_port=0,
     s = None
     # After 3.6 is no longer supported, this can use an AsyncExitStack.
     try:
+        af = dns.inet.af_for_address(where)
+        destination = _lltuple((where, port), af)
         if sock:
             s = sock
         else:
             if not backend:
                 backend = dns.asyncbackend.get_default_backend()
-            af = dns.inet.af_for_address(where)
             stuple = _source_tuple(af, source, source_port)
             s = await backend.make_socket(af, socket.SOCK_DGRAM, 0, stuple)
-            destination = _lltuple((where, port), af)
         await send_udp(s, wire, destination, expiration)
         (r, received_time) = await receive_udp(s, destination, expiration,
                                                ignore_unexpected,