Browse Source

Check future state before setting result in View

pull/6987/head
Rapptz 4 years ago
parent
commit
c21d12be5e
  1. 3
      discord/ui/view.py

3
discord/ui/view.py

@ -250,6 +250,7 @@ class View:
self._timeout_handler = loop.call_later(self.timeout, self.dispatch_timeout) self._timeout_handler = loop.call_later(self.timeout, self.dispatch_timeout)
def dispatch_timeout(self): def dispatch_timeout(self):
if not self._stopped.done():
self._stopped.set_result(True) self._stopped.set_result(True)
asyncio.create_task(self.on_timeout(), name=f'discord-ui-view-timeout-{self.id}') asyncio.create_task(self.on_timeout(), name=f'discord-ui-view-timeout-{self.id}')
@ -282,7 +283,9 @@ class View:
This operation cannot be undone. This operation cannot be undone.
""" """
if not self._stopped.done():
self._stopped.set_result(False) self._stopped.set_result(False)
if self._timeout_handler: if self._timeout_handler:
self._timeout_handler.cancel() self._timeout_handler.cancel()

Loading…
Cancel
Save