Browse Source

[tasks] Lazily fetch event loop if one isn't provided

Fixes #5808
pull/5813/head
Rapptz 5 years ago
parent
commit
ccdf4c4ad6
  1. 5
      discord/ext/tasks/__init__.py

5
discord/ext/tasks/__init__.py

@ -45,7 +45,7 @@ class Loop:
def __init__(self, coro, seconds, hours, minutes, count, reconnect, loop):
self.coro = coro
self.reconnect = reconnect
self.loop = loop or asyncio.get_event_loop()
self.loop = loop
self.count = count
self._current_loop = 0
self._task = None
@ -187,6 +187,9 @@ class Loop:
if self._injected is not None:
args = (self._injected, *args)
if self.loop is None:
self.loop = asyncio.get_event_loop()
self._task = self.loop.create_task(self._loop(*args, **kwargs))
return self._task

Loading…
Cancel
Save