From d4bafffa58f8ee572916763a6f0b25b54e1fd779 Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Sat, 23 Nov 2024 16:07:41 +0000 Subject: [PATCH] lsp-devtools: Apply ruff fixes --- lib/lsp-devtools/lsp_devtools/agent/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/lsp-devtools/lsp_devtools/agent/client.py b/lib/lsp-devtools/lsp_devtools/agent/client.py index 571819f..43d062d 100644 --- a/lib/lsp-devtools/lsp_devtools/agent/client.py +++ b/lib/lsp-devtools/lsp_devtools/agent/client.py @@ -25,6 +25,7 @@ def __init__(self): ) self.connected = False self._buffer: list[bytes] = [] + self._tasks: set[asyncio.Task[Any]] = set() def _report_server_error(self, error, source): # Bail on error @@ -61,8 +62,12 @@ def forward_message(self, message: bytes): while len(self._buffer) > 0: res = self.protocol.writer.write(self._buffer.pop(0)) if inspect.isawaitable(res): - asyncio.ensure_future(res) + task = asyncio.ensure_future(res) + task.add_done_callback(self._tasks.discard) + self._tasks.add(task) res = self.protocol.writer.write(message) if inspect.isawaitable(res): - asyncio.ensure_future(res) + task = asyncio.ensure_future(res) + task.add_done_callback(self._tasks.discard) + self._tasks.add(task)