summaryrefslogtreecommitdiff
path: root/dns
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-06-12 13:59:19 -0700
committerBob Halley <halley@dnspython.org>2020-06-12 13:59:19 -0700
commit0aef9b6b5ee2894a026b1850caa77855a40075c0 (patch)
tree66062b47534197b31d48554aea1b49780a6c34a6 /dns
parentd767922a498c8e683bbcaf32175d33c3216b76c9 (diff)
downloaddnspython-0aef9b6b5ee2894a026b1850caa77855a40075c0.tar.gz
only get_default_backend() when we need to, remove obsolete comment
Diffstat (limited to 'dns')
-rw-r--r--dns/asyncquery.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/dns/asyncquery.py b/dns/asyncquery.py
index d1c1793..68d1a35 100644
--- a/dns/asyncquery.py
+++ b/dns/asyncquery.py
@@ -186,8 +186,6 @@ async def udp(q, where, timeout=None, port=53, source=None, source_port=0,
Returns a ``dns.message.Message``.
"""
- if not backend:
- backend = dns.asyncbackend.get_default_backend()
wire = q.to_wire()
(begin_time, expiration) = _compute_times(timeout)
s = None
@@ -195,6 +193,8 @@ async def udp(q, where, timeout=None, port=53, source=None, source_port=0,
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)
@@ -388,8 +388,6 @@ async def tcp(q, where, timeout=None, port=53, source=None, source_port=0,
Returns a ``dns.message.Message``.
"""
- if not backend:
- backend = dns.asyncbackend.get_default_backend()
wire = q.to_wire()
(begin_time, expiration) = _compute_times(timeout)
s = None
@@ -407,6 +405,8 @@ async def tcp(q, where, timeout=None, port=53, source=None, source_port=0,
af = dns.inet.af_for_address(where)
stuple = _source_tuple(af, source, source_port)
dtuple = (where, port)
+ if not backend:
+ backend = dns.asyncbackend.get_default_backend()
s = await backend.make_socket(af, socket.SOCK_STREAM, 0, stuple,
dtuple, timeout)
await send_tcp(s, wire, expiration)
@@ -468,8 +468,6 @@ async def tls(q, where, timeout=None, port=853, source=None, source_port=0,
Returns a ``dns.message.Message``.
"""
- if not backend:
- backend = dns.asyncbackend.get_default_backend()
(begin_time, expiration) = _compute_times(timeout)
if not sock:
if ssl_context is None:
@@ -482,15 +480,14 @@ async def tls(q, where, timeout=None, port=853, source=None, source_port=0,
af = dns.inet.af_for_address(where)
stuple = _source_tuple(af, source, source_port)
dtuple = (where, port)
+ if not backend:
+ backend = dns.asyncbackend.get_default_backend()
s = await backend.make_socket(af, socket.SOCK_STREAM, 0, stuple,
dtuple, timeout, ssl_context,
server_hostname)
else:
s = sock
try:
- #
- # If a socket was provided, there's no special TLS handling needed.
- #
timeout = _timeout(expiration)
response = await tcp(q, where, timeout, port, source, source_port,
one_rr_per_rrset, ignore_trailing, s, backend)