From 8fce374caeded4bfe749571b57ab0b907d5af997 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 6 Aug 2019 02:18:07 -0300 Subject: [PATCH] race condition where the request is sent and connection lost right after --- torba/torba/rpc/session.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/torba/torba/rpc/session.py b/torba/torba/rpc/session.py index c8b8c6945..049cd22ed 100644 --- a/torba/torba/rpc/session.py +++ b/torba/torba/rpc/session.py @@ -473,6 +473,8 @@ class RPCSession(SessionBase): async def send_request(self, method, args=()): """Send an RPC request over the network.""" + if self.is_closing(): + raise CancelledError() message, event = self.connection.send_request(Request(method, args)) await self._send_message(message) await event.wait()