From bb517ddccaafae2081d8ff0d041a22f0b1f94411 Mon Sep 17 00:00:00 2001 From: Ryu juheon Date: Wed, 19 Jan 2022 15:09:17 +0900 Subject: [PATCH] fix: deprecation warning in ``asyncio.wait`` (#2383) --- sanic/server/websockets/impl.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sanic/server/websockets/impl.py b/sanic/server/websockets/impl.py index ed0d7fed81..aaccfaca73 100644 --- a/sanic/server/websockets/impl.py +++ b/sanic/server/websockets/impl.py @@ -518,8 +518,12 @@ async def recv(self, timeout: Optional[float] = None) -> Optional[Data]: ) try: self.recv_cancel = asyncio.Future() + tasks = ( + self.recv_cancel, + asyncio.ensure_future(self.assembler.get(timeout)), + ) done, pending = await asyncio.wait( - (self.recv_cancel, self.assembler.get(timeout)), + tasks, return_when=asyncio.FIRST_COMPLETED, ) done_task = next(iter(done)) @@ -570,8 +574,12 @@ async def recv_burst(self, max_recv=256) -> Sequence[Data]: self.can_pause = False self.recv_cancel = asyncio.Future() while True: + tasks = ( + self.recv_cancel, + asyncio.ensure_future(self.assembler.get(timeout=0)), + ) done, pending = await asyncio.wait( - (self.recv_cancel, self.assembler.get(timeout=0)), + tasks, return_when=asyncio.FIRST_COMPLETED, ) done_task = next(iter(done))