aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorNadir Chowdhury <[email protected]>2021-04-06 01:31:03 +0100
committerGitHub <[email protected]>2021-04-05 20:31:03 -0400
commit2ff24a27b593b6b562d61e16e45b525ad8a0276a (patch)
tree73be18e29bce411a14afe2c1ebfcaca456d3f93c /discord
parentRemove fail-safe for retrieving all tasks (diff)
downloaddiscord.py-2ff24a27b593b6b562d61e16e45b525ad8a0276a.tar.xz
discord.py-2ff24a27b593b6b562d61e16e45b525ad8a0276a.zip
Use `asyncio.create_task` over `asyncio.ensure_future`
Diffstat (limited to 'discord')
-rw-r--r--discord/message.py2
-rw-r--r--discord/state.py12
-rw-r--r--discord/utils.py2
-rw-r--r--discord/webhook.py2
4 files changed, 9 insertions, 9 deletions
diff --git a/discord/message.py b/discord/message.py
index c017cdd1..a19f44ab 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -971,7 +971,7 @@ class Message(Hashable):
except HTTPException:
pass
- asyncio.ensure_future(delete(), loop=self._state.loop)
+ asyncio.create_task(delete())
else:
await self._state.http.delete_message(self.channel.id, self.id)
diff --git a/discord/state.py b/discord/state.py
index dc2619b9..3d74b174 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -456,7 +456,7 @@ class ConnectionState:
self._add_guild_from_data(guild_data)
self.dispatch('connect')
- self._ready_task = asyncio.ensure_future(self._delay_ready(), loop=self.loop)
+ self._ready_task = asyncio.create_task(self._delay_ready())
def parse_resumed(self, data):
self.dispatch('resumed')
@@ -828,7 +828,7 @@ class ConnectionState:
# check if it requires chunking
if self._guild_needs_chunking(guild):
- asyncio.ensure_future(self._chunk_and_dispatch(guild, unavailable), loop=self.loop)
+ asyncio.create_task(self._chunk_and_dispatch(guild, unavailable))
return
# Dispatch available if newly available
@@ -968,7 +968,7 @@ class ConnectionState:
voice = self._get_voice_client(guild.id)
if voice is not None:
coro = voice.on_voice_state_update(data)
- asyncio.ensure_future(logging_coroutine(coro, info='Voice Protocol voice state update handler'))
+ asyncio.create_task(logging_coroutine(coro, info='Voice Protocol voice state update handler'))
member, before, after = guild._update_voice_state(data, channel_id)
if member is not None:
@@ -992,7 +992,7 @@ class ConnectionState:
vc = self._get_voice_client(key_id)
if vc is not None:
coro = vc.on_voice_server_update(data)
- asyncio.ensure_future(logging_coroutine(coro, info='Voice Protocol voice server update handler'))
+ asyncio.create_task(logging_coroutine(coro, info='Voice Protocol voice server update handler'))
def parse_typing_start(self, data):
channel, guild = self._get_guild_channel(data)
@@ -1104,7 +1104,7 @@ class AutoShardedConnectionState(ConnectionState):
current_bucket = []
# Chunk the guild in the background while we wait for GUILD_CREATE streaming
- future = asyncio.ensure_future(self.chunk_guild(guild))
+ future = asyncio.create_task(self.chunk_guild(guild))
current_bucket.append(future)
else:
future = self.loop.create_future()
@@ -1171,7 +1171,7 @@ class AutoShardedConnectionState(ConnectionState):
gc.collect()
if self._ready_task is None:
- self._ready_task = asyncio.ensure_future(self._delay_ready(), loop=self.loop)
+ self._ready_task = asyncio.create_task(self._delay_ready())
def parse_resumed(self, data):
self.dispatch('resumed')
diff --git a/discord/utils.py b/discord/utils.py
index 03478b3f..fec7b5c0 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -369,7 +369,7 @@ async def async_all(gen, *, check=_isawaitable):
async def sane_wait_for(futures, *, timeout):
ensured = [
- asyncio.ensure_future(fut) for fut in futures
+ asyncio.create_task(fut) for fut in futures
]
done, pending = await asyncio.wait(ensured, timeout=timeout, return_when=asyncio.ALL_COMPLETED)
diff --git a/discord/webhook.py b/discord/webhook.py
index 748fed7e..d14ad8fd 100644
--- a/discord/webhook.py
+++ b/discord/webhook.py
@@ -477,7 +477,7 @@ class WebhookMessage(Message):
except HTTPException:
pass
- asyncio.ensure_future(inner_call(), loop=self._state.loop)
+ asyncio.create_task(inner_call())
return await asyncio.sleep(0)
def delete(self, *, delay=None):