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:
|
except HTTPException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
asyncio.ensure_future(delete(), loop=self._state.loop)
|
asyncio.create_task(delete())
|
||||||
else:
|
else:
|
||||||
await self._state.http.delete_message(self.channel.id, self.id)
|
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._add_guild_from_data(guild_data)
|
||||||
|
|
||||||
self.dispatch('connect')
|
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):
|
def parse_resumed(self, data):
|
||||||
self.dispatch('resumed')
|
self.dispatch('resumed')
|
||||||
@ -828,7 +828,7 @@ class ConnectionState:
|
|||||||
|
|
||||||
# check if it requires chunking
|
# check if it requires chunking
|
||||||
if self._guild_needs_chunking(guild):
|
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
|
return
|
||||||
|
|
||||||
# Dispatch available if newly available
|
# Dispatch available if newly available
|
||||||
@ -968,7 +968,7 @@ class ConnectionState:
|
|||||||
voice = self._get_voice_client(guild.id)
|
voice = self._get_voice_client(guild.id)
|
||||||
if voice is not None:
|
if voice is not None:
|
||||||
coro = voice.on_voice_state_update(data)
|
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)
|
member, before, after = guild._update_voice_state(data, channel_id)
|
||||||
if member is not None:
|
if member is not None:
|
||||||
@ -992,7 +992,7 @@ class ConnectionState:
|
|||||||
vc = self._get_voice_client(key_id)
|
vc = self._get_voice_client(key_id)
|
||||||
if vc is not None:
|
if vc is not None:
|
||||||
coro = vc.on_voice_server_update(data)
|
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):
|
def parse_typing_start(self, data):
|
||||||
channel, guild = self._get_guild_channel(data)
|
channel, guild = self._get_guild_channel(data)
|
||||||
@ -1104,7 +1104,7 @@ class AutoShardedConnectionState(ConnectionState):
|
|||||||
current_bucket = []
|
current_bucket = []
|
||||||
|
|
||||||
# Chunk the guild in the background while we wait for GUILD_CREATE streaming
|
# 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)
|
current_bucket.append(future)
|
||||||
else:
|
else:
|
||||||
future = self.loop.create_future()
|
future = self.loop.create_future()
|
||||||
@ -1171,7 +1171,7 @@ class AutoShardedConnectionState(ConnectionState):
|
|||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
if self._ready_task is None:
|
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):
|
def parse_resumed(self, data):
|
||||||
self.dispatch('resumed')
|
self.dispatch('resumed')
|
||||||
|
@ -369,7 +369,7 @@ async def async_all(gen, *, check=_isawaitable):
|
|||||||
|
|
||||||
async def sane_wait_for(futures, *, timeout):
|
async def sane_wait_for(futures, *, timeout):
|
||||||
ensured = [
|
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)
|
done, pending = await asyncio.wait(ensured, timeout=timeout, return_when=asyncio.ALL_COMPLETED)
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ class WebhookMessage(Message):
|
|||||||
except HTTPException:
|
except HTTPException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
asyncio.ensure_future(inner_call(), loop=self._state.loop)
|
asyncio.create_task(inner_call())
|
||||||
return await asyncio.sleep(0)
|
return await asyncio.sleep(0)
|
||||||
|
|
||||||
def delete(self, *, delay=None):
|
def delete(self, *, delay=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user