From ff39a7be8cf8e5e0d03bfae3adfa00a73d0fe2c7 Mon Sep 17 00:00:00 2001 From: AlexWells Date: Thu, 13 Apr 2023 15:32:55 +0100 Subject: [PATCH] Create a task to pass to asyncio.wait In Python3.8+ passing the raw Future is deprecated. --- pandablocks/asyncio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandablocks/asyncio.py b/pandablocks/asyncio.py index 0f93126e9..bc1f63fa2 100644 --- a/pandablocks/asyncio.py +++ b/pandablocks/asyncio.py @@ -32,7 +32,8 @@ async def write_and_drain(self, data: bytes, timeout: Optional[float] = None): # Cannot simply await the drain, as if the remote end has disconnected # then the drain will never complete as the OS cannot clear its send buffer. - _, pending = await asyncio.wait([writer.drain()], timeout=timeout) + write_task = asyncio.create_task(writer.drain()) + _, pending = await asyncio.wait([write_task], timeout=timeout) if len(pending): for task in pending: task.cancel()