diff options
| author | Rapptz <[email protected]> | 2021-06-06 07:05:17 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-06-06 07:05:17 -0400 |
| commit | 81e9d70b7bd168f68d4f4e708812a4371c96bbcd (patch) | |
| tree | 57b5fc576b462c60ac9a7c4a67d00a2f79a00b5b | |
| parent | Add View.on_error callback for swallowed exceptions (diff) | |
| download | discord.py-81e9d70b7bd168f68d4f4e708812a4371c96bbcd.tar.xz discord.py-81e9d70b7bd168f68d4f4e708812a4371c96bbcd.zip | |
Add pre-conditions to avoid on_timeout being called after stop()
Apparently the cancellation request for a TimerHandle doesn't
necessarily have to be honoured despite large periods of time passing
| -rw-r--r-- | discord/ui/view.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/discord/ui/view.py b/discord/ui/view.py index 38ca9763..e651be7b 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -314,8 +314,10 @@ class View: self._timeout_handler = loop.call_later(self.timeout, self.dispatch_timeout) def dispatch_timeout(self): - if not self._stopped.done(): - self._stopped.set_result(True) + if self._stopped.done(): + return + + self._stopped.set_result(True) asyncio.create_task(self.on_timeout(), name=f'discord-ui-view-timeout-{self.id}') def dispatch(self, state: Any, item: Item, interaction: Interaction): |