PaddedRSTransport: fix busy loop in poll_sbuffer (follow-up 43ca469774)
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user