mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Use asyncio.create_task
over asyncio.ensure_future
This commit is contained in:
parent
7a7c4b4d62
commit
2ff24a27b5
@ -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)
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user