From 4ef0fb0d959b69d3b2cea87b0fc08310028e348f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 20 Nov 2019 03:04:04 -0500 Subject: [PATCH] Fix more deprecation warnings --- discord/gateway.py | 2 +- discord/shard.py | 2 +- discord/utils.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/discord/gateway.py b/discord/gateway.py index 81c7c09f0..f2dc7fcbb 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -389,7 +389,7 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): if op == self.INVALIDATE_SESSION: if data is True: - await asyncio.sleep(5.0, loop=self.loop) + await asyncio.sleep(5.0) await self.close() raise ResumeWebSocket(self.shard_id) diff --git a/discord/shard.py b/discord/shard.py index 09891bd8c..3e85d4458 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -289,7 +289,7 @@ class AutoShardedClient(Client): except Exception: pass - to_close = [shard.ws.close() for shard in self.shards.values()] + to_close = [asyncio.ensure_future(shard.ws.close(), loop=self.loop) for shard in self.shards.values()] if to_close: await asyncio.wait(to_close) diff --git a/discord/utils.py b/discord/utils.py index 2b4f0fda9..bc2815024 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -328,7 +328,10 @@ async def async_all(gen, *, check=_isawaitable): return True async def sane_wait_for(futures, *, timeout): - done, pending = await asyncio.wait(futures, timeout=timeout, return_when=asyncio.ALL_COMPLETED) + ensured = [ + asyncio.ensure_future(fut) for fut in futures + ] + done, pending = await asyncio.wait(ensured, timeout=timeout, return_when=asyncio.ALL_COMPLETED) if len(pending) != 0: raise asyncio.TimeoutError()