Skip to content

Commit

Permalink
Merge pull request #48 from PandABlocks/fix-deprecation-warning
Browse files Browse the repository at this point in the history
Create a task to pass to asyncio.wait
  • Loading branch information
coretl committed Sep 1, 2023
2 parents e24fdfc + ff39a7b commit f99c713
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pandablocks/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f99c713

Please sign in to comment.