From 57704600d94cff0ccce39b3ff39af6e969312a84 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 2 Jun 2025 15:24:00 +0000 Subject: [PATCH] interface: make sure interface.taskgroup gets cleaned up follow-up https://github.com/spesmilo/electrum/commit/0ce89b6d544dd1a5d192014f14a82aec9f05543f --- electrum/interface.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/electrum/interface.py b/electrum/interface.py index 4809013f6..6ecf7850b 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -360,6 +360,7 @@ class PaddedRSTransport(RSTransport): async def _poll_sbuffer(self): while not self.is_closing(): + await self._can_send.wait() await self._sbuffer_has_data_evt.wait() # to avoid busy-waiting self._maybe_consume_sbuffer() # If there is still data in the buffer, sleep until it would time out. @@ -639,6 +640,9 @@ class Interface(Logger): self.logger.debug(f"(disconnect) trace for {repr(e)}", exc_info=True) finally: self.got_disconnected.set() + # Make sure taskgroup gets cleaned-up. This explicit clean-up is needed here + # in case the "with taskgroup" ctx mgr never got a chance to run: + await self.taskgroup.cancel_remaining() await self.network.connection_down(self) # if was not 'ready' yet, schedule waiting coroutines: self.ready.cancel()