]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Fix more issues with asyncio and timeouts [#962].
authorBob Halley <halley@dnspython.org>
Wed, 19 Jul 2023 15:42:58 +0000 (08:42 -0700)
committerBob Halley <halley@dnspython.org>
Wed, 19 Jul 2023 15:43:15 +0000 (08:43 -0700)
dns/_asyncio_backend.py
dns/quic/_asyncio.py

index 64325351d05c673922ff2f2d6ac6ed4862293133..94f751b1bdd1b699528fabfb199c4b0835b3db88 100644 (file)
@@ -37,7 +37,14 @@ class _DatagramProtocol:
 
     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()
index cf1de8ec04026ebdddd76ccd958975e9d7e0660a..e1c52339d30ca0332593254fbaaed677657e74f1 100644 (file)
@@ -188,6 +188,7 @@ class AsyncioQuicConnection(AsyncQuicConnection):
             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: