summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-06-24 07:49:51 -0400
committermorpheus65535 <[email protected]>2022-06-24 07:49:51 -0400
commitf543368089f5cbb223621015c22ea068ad8c86a0 (patch)
tree1c83c3849d037ff3af20b9357607041e8532b903
parentc8c815e24095b98882ac58f9961e63b38b63a20c (diff)
downloadbazarr-f543368089f5cbb223621015c22ea068ad8c86a0.tar.gz
bazarr-f543368089f5cbb223621015c22ea068ad8c86a0.zip
Fixed DNS queries caching issue.v1.0.5-beta.34
-rw-r--r--libs/subliminal_patch/http.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/subliminal_patch/http.py b/libs/subliminal_patch/http.py
index 4f1339b39..f93b2d00b 100644
--- a/libs/subliminal_patch/http.py
+++ b/libs/subliminal_patch/http.py
@@ -320,14 +320,16 @@ def patch_create_connection():
"""Wrap urllib3's create_connection to resolve the name elsewhere"""
# resolve hostname to an ip address; use your own
# resolver here, as otherwise the system resolver will be used.
+ __custom_resolver_ips = os.environ.get("dns_resolvers", None)
+ if not __custom_resolver_ips:
+ return _orig_create_connection(address, *args, **kwargs)
+
global _custom_resolver, _custom_resolver_ips, dns_cache
host, port = address
try:
ipaddress.ip_address(six.text_type(host))
except (ipaddress.AddressValueError, ValueError):
- __custom_resolver_ips = os.environ.get("dns_resolvers", None)
-
# resolver ips changed in the meantime?
if __custom_resolver_ips != _custom_resolver_ips:
_custom_resolver = None
@@ -362,7 +364,7 @@ def patch_create_connection():
except dns.exception.DNSException:
logger.warning("DNS: Couldn't resolve %s with DNS: %s", host, custom_resolver.nameservers)
- # logger.debug("DNS: Falling back to default DNS or IP on %s", host) <-- commented because it makes way too much noise in debug logs
+ logger.debug("DNS: Falling back to default DNS or IP on %s", host)
return _orig_create_connection((host, port), *args, **kwargs)
patch_create_connection._sz_patched = True