From 162254c537cf474404a15946bd9865d27a357ecf Mon Sep 17 00:00:00 2001 From: gerlofvanek Date: Wed, 28 Jan 2026 23:42:24 +0100 Subject: [PATCH] Added graceful shutdown for electrum. --- basicswap/basicswap.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 299b222..00d8534 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -740,6 +740,15 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp): self._network.stopNetwork() self._network = None + for coin_type, interface in self.coin_interfaces.items(): + if hasattr(interface, "_backend") and interface._backend is not None: + try: + if hasattr(interface._backend, "_server"): + interface._backend._server.disconnect() + self.log.debug(f"Disconnected electrum backend for {coin_type}") + except Exception as e: + self.log.debug(f"Error disconnecting electrum backend: {e}") + self.log.info("Stopping threads.") for t in self.threads: if hasattr(t, "stop") and callable(t.stop):