diff options
| author | Rapptz <[email protected]> | 2019-05-12 01:31:09 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-05-12 01:31:09 -0400 |
| commit | 49a7e58d17de0fb519f0dc4636f40f3b3526ed6d (patch) | |
| tree | 5df444a8c59b9ca83def6892d10b0c980c0b7a07 | |
| parent | [tasks] Add Loop.stop to gracefully stop a task. (diff) | |
| download | discord.py-49a7e58d17de0fb519f0dc4636f40f3b3526ed6d.tar.xz discord.py-49a7e58d17de0fb519f0dc4636f40f3b3526ed6d.zip | |
[tasks] Keep retrying before gracefully exiting.
| -rw-r--r-- | discord/ext/tasks/__init__.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 7b2aface..ad52f549 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -74,8 +74,6 @@ class Loop: except self._valid_exception as exc: if not self.reconnect: raise - if self._stop_next_iteration: - return await asyncio.sleep(backoff.delay()) else: if self._stop_next_iteration: @@ -141,6 +139,16 @@ class Loop: Unlike :meth:`cancel`\, this allows the task to finish its current iteration before gracefully exiting. + .. note:: + + If the internal function raises an error that can be + handled before finishing then it will retry until + it succeeds. + + If this is undesirable, either remove the error handling + before stopping via :meth:`clear_exception_types` or + use :meth:`cancel` instead. + .. versionadded:: 1.2 """ if self._task and not self._task.done(): |