Skip to content

Commit

Permalink
Fix more issues with asyncio and timeouts [#962].
Browse files Browse the repository at this point in the history
(cherry picked from commit 76eb9e8)
  • Loading branch information
rthalley committed Jul 19, 2023
1 parent 7431295 commit a070c2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dns/_asyncio_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def error_received(self, exc): # pragma: no cover

def connection_lost(self, exc):
if self.recvfrom and not self.recvfrom.done():
self.recvfrom.set_exception(exc)
if exc is None:
# EOF we triggered. Is there a better way to do this?
try:
raise EOFError
except EOFError as e:
self.recvfrom.set_exception(e)
else:
self.recvfrom.set_exception(exc)

def close(self):
self.transport.close()
Expand Down
1 change: 1 addition & 0 deletions dns/quic/_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ async def close(self):
self._connection.close()
# sender might be blocked on this, so set it
self._socket_created.set()
await self._socket.close()
async with self._wake_timer:
self._wake_timer.notify_all()
try:
Expand Down

0 comments on commit a070c2b

Please sign in to comment.