Skip to content

Commit

Permalink
WIP: Upgrade aiohttp and set timeout on DNS lookup
Browse files Browse the repository at this point in the history
TODO: Python 3.9 compatibility
  • Loading branch information
smsearcy committed May 15, 2024
1 parent 7ec4d68 commit fa52ab5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 4 additions & 1 deletion meshinfo/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ async def reverse_dns_lookup(
"""
with bound_contextvars(ip_address=ip_address):
logger.debug("Reverse DNS lookup", dns_server=dns_server)
loop = asyncio.get_running_loop()
on_con_lost = loop.create_future()
transport, protocol = await loop.create_datagram_endpoint(
Expand All @@ -116,7 +117,9 @@ async def reverse_dns_lookup(
)

try:
response = await on_con_lost
# FIXME: use async-timeout package for Python 3.9 compatibility
async with asyncio.timeout(5):
response = await on_con_lost
except Exception as exc:
logger.exception("Error querying DNS server", error=exc)
return ""
Expand Down
6 changes: 1 addition & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
#
# pip-compile --output-file=requirements.txt pyproject.toml
#
aiohttp==3.8.6
aiohttp==3.9.5
# via mesh-info (pyproject.toml)
aiosignal==1.3.1
# via aiohttp
alembic==1.12.1
# via mesh-info (pyproject.toml)
async-timeout==4.0.3
# via aiohttp
attrs==23.1.0
# via
# aiohttp
# environ-config
# mesh-info (pyproject.toml)
charset-normalizer==3.3.1
# via aiohttp
environ-config==23.2.0
# via mesh-info (pyproject.toml)
frozenlist==1.4.0
Expand Down

0 comments on commit fa52ab5

Please sign in to comment.