[tasks] Rename Loop.run to Loop.start to avoid blocking connotations

This commit is contained in:
Rapptz 2019-04-11 08:19:32 -04:00
parent b0c7f48caf
commit 10bc939348
2 changed files with 6 additions and 6 deletions

View File

@ -75,8 +75,8 @@ class Loop:
return self._current_loop return self._current_loop
def run(self, *args, **kwargs): def start(self, *args, **kwargs):
r"""Runs the internal task in the event loop. r"""Starts the internal task in the event loop.
Parameters Parameters
------------ ------------
@ -93,7 +93,7 @@ class Loop:
Returns Returns
--------- ---------
:class:`asyncio.Task` :class:`asyncio.Task`
The task that has been registered. The task that has been created.
""" """
if self._task is not None: if self._task is not None:

View File

@ -21,7 +21,7 @@ A simple background task in a :class:`~discord.ext.commands.Cog`:
class MyCog(commands.Cog): class MyCog(commands.Cog):
def __init__(self): def __init__(self):
self.index = 0 self.index = 0
self.printer.run() self.printer.start()
def cog_unload(self): def cog_unload(self):
self.printer.cancel() self.printer.cancel()
@ -43,7 +43,7 @@ Adding an exception to handle during reconnect:
self.bot = bot self.bot = bot
self.data = [] self.data = []
self.batch_update.add_exception_type(asyncpg.PostgresConnectionError) self.batch_update.add_exception_type(asyncpg.PostgresConnectionError)
self.batch_update.run() self.batch_update.start()
def cog_unload(self): def cog_unload(self):
self.batch_update.cancel() self.batch_update.cancel()
@ -64,7 +64,7 @@ Looping a certain amount of times before exiting:
async def slow_count(): async def slow_count():
print(slow_count.current_loop) print(slow_count.current_loop)
slow_count.run() slow_count.start()
Doing something after a task finishes is as simple as using :meth:`asyncio.Task.add_done_callback`: Doing something after a task finishes is as simple as using :meth:`asyncio.Task.add_done_callback`: