Allow start when the loop is not running

This commit is contained in:
Lonami Exo
2018-06-25 13:42:29 +02:00
parent db5cb74bdd
commit 9c6d2894fc
2 changed files with 28 additions and 6 deletions

View File

@@ -32,10 +32,11 @@ class UpdateMethods(UserMethods):
If the loop is already running, this method returns a coroutine
that you should await on your own code.
"""
if self.loop.is_running():
return self._run_until_disconnected() # Let the user await it
else:
self.loop.run_until_complete(self._run_until_disconnected())
coro = self._run_until_disconnected()
return (
coro if self.loop.is_running()
else self.loop.run_until_complete(coro)
)
def on(self, event):
"""