diff --git a/dns_unbound_cache_reader/dns_unbound_cache_reader.py b/dns_unbound_cache_reader/dns_unbound_cache_reader.py index a7bdbcf2662a4986ca972e4fcd138499d19797fe..3d7056ad8bd43c5ee59d3855a3386166de693584 100644 --- a/dns_unbound_cache_reader/dns_unbound_cache_reader.py +++ b/dns_unbound_cache_reader/dns_unbound_cache_reader.py @@ -79,8 +79,9 @@ def update_dns_table( if host in localhost: ## Unbound runs on localhost - proc = subprocess.run(cmd.split(), capture_output=True) - dns_cache = proc.stdout.decode().strip().split("\n") + proc = subprocess.run(cmd.split(), capture_output=True, text=True) + dns_cache = proc.stdout.strip().split("\n") + del proc else: ## Unbound runs on a remote host @@ -90,6 +91,9 @@ def update_dns_table( # Get the DNS cache result = remote.run(cmd) dns_cache = result.stdout.strip().split("\n") + # Free resources + del remote + del result else: # Read DNS cache from file