From 2f4b4d97e7e44cdf90b0824e72d4d758434a5dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 28 Jul 2017 01:23:23 +0200 Subject: [PATCH] api: fix handling interrupted calls When an API call is interrupted, the relevant coroutine is cancelled - which means it may throw CancelledError. At the same time, cancelled call have related socket already closed (and transport set to None). But QubesDaemonProtocol.respond try to close the transport again, which fails. Fix handling this case. --- qubes/api/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubes/api/__init__.py b/qubes/api/__init__.py index f35974ec..4998b031 100644 --- a/qubes/api/__init__.py +++ b/qubes/api/__init__.py @@ -307,7 +307,8 @@ class QubesDaemonProtocol(asyncio.Protocol): # this is reached if from except: blocks; do not put it in finally:, # because this will prevent the good case from sending the reply - self.transport.abort() + if self.transport: + self.transport.abort() def send_header(self, *args): self.transport.write(self.header.pack(*args))