From 7d74fd0201bd6b89013867de250c3e5867824fe2 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 23 Feb 2022 18:37:21 +0100 Subject: [PATCH] interface: add comment about monitor_connection --- electrum/interface.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/electrum/interface.py b/electrum/interface.py index 8d118900f..7c3ae041f 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -681,6 +681,15 @@ class Interface(Logger): async def monitor_connection(self): while True: await asyncio.sleep(1) + # If the session/transport is no longer open, we disconnect. + # e.g. if the remote cleanly sends EOF, we would handle that here. + # note: If the user pulls the ethernet cable or disconnects wifi, + # ideally we would detect that here, so that the GUI/etc can reflect that. + # - On Android, this seems to work reliably , where asyncio.BaseProtocol.connection_lost() + # gets called with e.g. ConnectionAbortedError(103, 'Software caused connection abort'). + # - On desktop Linux/Win, it seems BaseProtocol.connection_lost() is not called in such cases. + # Hence, in practice the connection issue will only be detected the next time we try + # to send a message (plus timeout), which can take minutes... if not self.session or self.session.is_closing(): raise GracefulDisconnect('session was closed')