aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-29 03:18:25 -0400
committerRapptz <[email protected]>2019-04-29 23:34:20 -0400
commit55e3e242ff8959a4ed52fc002273e7e2b6355e23 (patch)
tree369b2d457bbc9ed21d92c66fbee4237239a6ea65 /discord
parentProper location of versionadded (diff)
downloaddiscord.py-55e3e242ff8959a4ed52fc002273e7e2b6355e23.tar.xz
discord.py-55e3e242ff8959a4ed52fc002273e7e2b6355e23.zip
[tasks] Remove support for awaitables due to gotchas.
Fixes #2079
Diffstat (limited to 'discord')
-rw-r--r--discord/ext/tasks/__init__.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py
index 374e91e8..a6425a8b 100644
--- a/discord/ext/tasks/__init__.py
+++ b/discord/ext/tasks/__init__.py
@@ -57,13 +57,10 @@ class Loop:
if coro is None:
return
- if inspect.iscoroutinefunction(coro):
- if self._injected is not None:
- await coro(self._injected)
- else:
- await coro()
+ if self._injected is not None:
+ await coro(self._injected)
else:
- await coro
+ await coro()
async def _loop(self, *args, **kwargs):
backoff = ExponentialBackoff()
@@ -193,14 +190,16 @@ class Loop:
return self._task
def before_loop(self, coro):
- """A function that also acts as a decorator to register a coroutine to be
- called before the loop starts running. This is useful if you want to wait
- for some bot state before the loop starts,
+ """A decorator that registers a coroutine to be called before the loop starts running.
+
+ This is useful if you want to wait for some bot state before the loop starts,
such as :meth:`discord.Client.wait_until_ready`.
+ The coroutine must take no arguments (except ``self`` in a class context).
+
Parameters
------------
- coro: :term:`py:awaitable`
+ coro: :ref:`coroutine <coroutine>`
The coroutine to register before the loop runs.
Raises
@@ -209,19 +208,20 @@ class Loop:
The function was not a coroutine.
"""
- if not (inspect.iscoroutinefunction(coro) or inspect.isawaitable(coro)):
- raise TypeError('Expected coroutine or awaitable, received {0.__name__!r}.'.format(type(coro)))
+ if not inspect.iscoroutinefunction(coro):
+ raise TypeError('Expected coroutine function, received {0.__name__!r}.'.format(type(coro)))
self._before_loop = coro
def after_loop(self, coro):
- """A function that also acts as a decorator to register a coroutine to be
- called after the loop finished running.
+ """A decorator that register a coroutine to be called after the loop finished running.
+
+ The coroutine must take no arguments (except ``self`` in a class context).
Parameters
------------
- coro: :term:`py:awaitable`
+ coro: :ref:`coroutine <coroutine>`
The coroutine to register after the loop finishes.
Raises
@@ -230,8 +230,8 @@ class Loop:
The function was not a coroutine.
"""
- if not (inspect.iscoroutinefunction(coro) or inspect.isawaitable(coro)):
- raise TypeError('Expected coroutine or awaitable, received {0.__name__!r}.'.format(type(coro)))
+ if not inspect.iscoroutinefunction(coro):
+ raise TypeError('Expected coroutine function, received {0.__name__!r}.'.format(type(coro)))
self._after_loop = coro