Skip to content

Commit

Permalink
fix: retry once on tcp request error
Browse files Browse the repository at this point in the history
close #31
  • Loading branch information
gera2ld committed Apr 10, 2024
1 parent e820664 commit ee92c6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion async_dns/request/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ async def request(req, addr, timeout=3.0):
'''
Send raw data with a connection pool.
'''
result = await asyncio.wait_for(_request(req, addr), timeout)
try:
result = await asyncio.wait_for(_request(req, addr), timeout)
except asyncio.IncompleteReadError:
# Retry once in case the existing connection is dead
result = await asyncio.wait_for(_request(req, addr), timeout)
return result


Expand Down

0 comments on commit ee92c6a

Please sign in to comment.