Skip to content

Commit 6d640c4

Browse files
committed
fix while loop
1 parent b2471a7 commit 6d640c4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/aleph/sdk/domain.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ async def get_ns_servers(self, hostname: Hostname):
4646
dns_servers = settings.DNS_RESOLVERS
4747
fqdn = hostname
4848

49-
stop = False
50-
while stop is False:
49+
while True:
5150
"""**Detect and get authoritative NS server of subdomains if delegated**"""
5251
try:
5352
entries = await self.resolver.query(fqdn, "NS")
@@ -57,15 +56,18 @@ async def get_ns_servers(self, hostname: Hostname):
5756
servers += await self.get_ipv4_addresses(entry.host)
5857

5958
dns_servers = servers
60-
stop = True
59+
break
6160
except aiodns.error.DNSError:
6261
sub_domains = fqdn.split(".")
6362
if len(sub_domains) > 2:
6463
fqdn = Hostname(".".join(sub_domains[1:]))
6564
continue
6665

6766
if len(sub_domains) == 2:
68-
stop = True
67+
break
68+
except Exception as err:
69+
logger.debug(f"Unexpected {err=}, {type(err)=}")
70+
break
6971

7072
return dns_servers
7173

0 commit comments

Comments
 (0)