Skip to content

Commit

Permalink
fix: deprecation warning in asyncio.wait (sanic-org#2383)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaidBySolo authored and ChihweiLHBird committed Jun 1, 2022
1 parent 3698ee3 commit ba38b70
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sanic/server/websockets/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit ba38b70

Please sign in to comment.