From 0ce89b6d544dd1a5d192014f14a82aec9f05543f Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 2 Jun 2025 13:22:32 +0200 Subject: [PATCH] PaddedRSTransport: fix busy loop in poll_sbuffer (follow-up 43ca469774bcbe88df7092ca78f9c6309c8bc42a) According to the asyncio documentation: > When a task is cancelled, asyncio.CancelledError will be raised in the task at the next opportunity. I guess the 'next opportunity' means the next await statement. Here the issue is that the task was not awaiting ever. Note: ElectrumX needs a similar patch --- electrum/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrum/interface.py b/electrum/interface.py index cf6d52821..4809013f6 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -359,7 +359,7 @@ class PaddedRSTransport(RSTransport): self._sbuffer_has_data_evt.clear() async def _poll_sbuffer(self): - while True: + while not self.is_closing(): 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.