mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
[tasks] Allow Loop.cancel in Loop.before_loop
Task cancel raises on the next awaited coro, so I've added this 0-sleep "hack" I'm internally debating if leaving the comment there, but I'm sure it would confuse the uninformed of this trick.
This commit is contained in:
parent
4f96e3b9a5
commit
4b3a7fbe16
@ -68,6 +68,7 @@ class Loop:
|
||||
sleep_until = discord.utils.sleep_until
|
||||
self._next_iteration = datetime.datetime.now(datetime.timezone.utc)
|
||||
try:
|
||||
await asyncio.sleep(0) # allows canceling in before_loop
|
||||
while True:
|
||||
self._last_iteration = self._next_iteration
|
||||
self._next_iteration = self._get_next_sleep_time()
|
||||
|
Loading…
x
Reference in New Issue
Block a user