diff options
| author | Rodolfo Alonso Hernandez <ralonsoh@redhat.com> | 2020-07-20 17:21:30 +0000 |
|---|---|---|
| committer | Sergey Shepelev <temotor@gmail.com> | 2020-07-30 20:08:32 +0300 |
| commit | adb2eebc14cbdd00f572a8f36b5e9cb6994b6d42 (patch) | |
| tree | 60daf7de4cd275b95021be42b269874b6c5a91f0 | |
| parent | fc8cc0f6a77896234284ef40d7226d62345922c0 (diff) | |
| download | eventlet-ralonsoh-619.tar.gz | |
Replace dnspython "_compute_expiration" by "_compute_times".ralonsoh-619
In dnspython v2.0.0, "_compute_expiration" was replaced by
"_compute_times". Once the minimum version of dnspython is
v2.0.0, we can remove this wrapping method.
Closes-Bug: #1888258
Fixes: #629
| -rw-r--r-- | eventlet/support/greendns.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/eventlet/support/greendns.py b/eventlet/support/greendns.py index 13968c2..19b83c9 100644 --- a/eventlet/support/greendns.py +++ b/eventlet/support/greendns.py @@ -118,6 +118,15 @@ def is_ip_addr(host): return is_ipv4_addr(host) or is_ipv6_addr(host) +def compute_expiration(query, timeout): + # NOTE(ralonsoh): in dnspython v2.0.0, "_compute_expiration" was replaced + # by "_compute_times". + if hasattr(query, '_compute_expiration'): + return query._compute_expiration(timeout) + else: + return query._compute_times(timeout)[1] + + class HostsAnswer(dns.resolver.Answer): """Answer class for HostsResolver object""" @@ -709,7 +718,7 @@ def udp(q, where, timeout=DNS_QUERY_TIMEOUT, port=53, s = socket.socket(af, socket.SOCK_DGRAM) s.settimeout(timeout) try: - expiration = dns.query._compute_expiration(timeout) + expiration = compute_expiration(dns.query, timeout) if source is not None: s.bind(source) while True: @@ -802,7 +811,7 @@ def tcp(q, where, timeout=DNS_QUERY_TIMEOUT, port=53, s = socket.socket(af, socket.SOCK_STREAM) s.settimeout(timeout) try: - expiration = dns.query._compute_expiration(timeout) + expiration = compute_expiration(dns.query, timeout) if source is not None: s.bind(source) while True: |
