aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-11 08:19:32 -0400
committerRapptz <[email protected]>2019-04-11 08:19:32 -0400
commit10bc93934876c3302bd2f9941f48b300c288be6e (patch)
tree33d63a594bf1ab030be1f3075699c2cac6035f15
parent[tasks] Add a new background helper 'tasks' extension. (diff)
downloaddiscord.py-10bc93934876c3302bd2f9941f48b300c288be6e.tar.xz
discord.py-10bc93934876c3302bd2f9941f48b300c288be6e.zip
[tasks] Rename Loop.run to Loop.start to avoid blocking connotations
-rw-r--r--discord/ext/tasks/__init__.py6
-rw-r--r--docs/ext/tasks/index.rst6
2 files changed, 6 insertions, 6 deletions
diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py
index 623513d1..1c5c791a 100644
--- a/discord/ext/tasks/__init__.py
+++ b/discord/ext/tasks/__init__.py
@@ -75,8 +75,8 @@ class Loop:
return self._current_loop
- def run(self, *args, **kwargs):
- r"""Runs the internal task in the event loop.
+ def start(self, *args, **kwargs):
+ r"""Starts the internal task in the event loop.
Parameters
------------
@@ -93,7 +93,7 @@ class Loop:
Returns
---------
:class:`asyncio.Task`
- The task that has been registered.
+ The task that has been created.
"""
if self._task is not None:
diff --git a/docs/ext/tasks/index.rst b/docs/ext/tasks/index.rst
index bb242679..aebb7f16 100644
--- a/docs/ext/tasks/index.rst
+++ b/docs/ext/tasks/index.rst
@@ -21,7 +21,7 @@ A simple background task in a :class:`~discord.ext.commands.Cog`:
class MyCog(commands.Cog):
def __init__(self):
self.index = 0
- self.printer.run()
+ self.printer.start()
def cog_unload(self):
self.printer.cancel()
@@ -43,7 +43,7 @@ Adding an exception to handle during reconnect:
self.bot = bot
self.data = []
self.batch_update.add_exception_type(asyncpg.PostgresConnectionError)
- self.batch_update.run()
+ self.batch_update.start()
def cog_unload(self):
self.batch_update.cancel()
@@ -64,7 +64,7 @@ Looping a certain amount of times before exiting:
async def slow_count():
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`: