diff options
| author | Bob Halley <halley@dnspython.org> | 2020-06-17 14:05:30 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-06-17 14:05:35 -0700 |
| commit | ffdd837961fceab98c763fb5fbc63ab157e78e9c (patch) | |
| tree | 808fe4064b43836e2f5bdcfb94688330e05ce565 /dns | |
| parent | 928de9b541521fb938b70e347f0cb0cb320423f7 (diff) | |
| download | dnspython-ffdd837961fceab98c763fb5fbc63ab157e78e9c.tar.gz | |
make passing a socket to async routines actually work
Diffstat (limited to 'dns')
| -rw-r--r-- | dns/_asyncbackend.py | 2 | ||||
| -rw-r--r-- | dns/asyncquery.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/dns/_asyncbackend.py b/dns/_asyncbackend.py index d96dce1..c7ecfad 100644 --- a/dns/_asyncbackend.py +++ b/dns/_asyncbackend.py @@ -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() diff --git a/dns/asyncquery.py b/dns/asyncquery.py index 709c246..b36a2f6 100644 --- a/dns/asyncquery.py +++ b/dns/asyncquery.py @@ -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, |
