Skip to content

Commit dbd9f1b

Browse files
blume0JustaSqu1d
andauthored
fix: reset exponential backoff after task runs successfully in tasks extension (#2700)
* [tasks] reset exponential backoff after task runs successfully The current behaviour of the _loop method (when the reconnect attribute is set to True) is to have the same ExponentialBackoff instance for all of its lifetime. A task that has failed n times over its life-time will thus wait 2**n seconds before retrying, no matter how many successful instances of happened between the failures. With this commit, the behaviour is to reset the exponential backoff after a succesful execution of the task, so that the backoff only takes place after successive failures. * Update CHANGELOG.md Signed-off-by: DaBlumer <30708312+DaBlumer@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: DaBlumer <30708312+DaBlumer@users.noreply.github.com> --------- Signed-off-by: DaBlumer <30708312+DaBlumer@users.noreply.github.com> Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com>
1 parent ad2ccad commit dbd9f1b

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ These changes are available on the `master` branch, but have not yet been releas
8181
- Fixed attachment metadata being set incorrectly in interaction responses causing the
8282
metadata to be ignored by Discord.
8383
([#2679](https://github.com/Pycord-Development/pycord/pull/2679))
84+
- Fixed unexpected backoff behavior in the handling of task failures
85+
([#2700](https://github.com/Pycord-Development/pycord/pull/2700)).
8486

8587
### Changed
8688

discord/ext/tasks/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ async def _loop(self, *args: Any, **kwargs: Any) -> None:
168168
try:
169169
await self.coro(*args, **kwargs)
170170
self._last_iteration_failed = False
171+
backoff = ExponentialBackoff()
171172
except self._valid_exception:
172173
self._last_iteration_failed = True
173174
if not self.reconnect:

0 commit comments

Comments
 (0)