Browse Source

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.
Marek Marczykowski-Górecki 6 years ago
parent
commit
2f4b4d97e7
1 changed files with 2 additions and 1 deletions
  1. 2 1
      qubes/api/__init__.py

+ 2 - 1
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))