Compare commits
No commits in common. "236e24af4adba8dadcb24cbd424298c356d59576" and "f4317339409fbbfe7467e4b213c6da1d54835a75" have entirely different histories.
236e24af4a
...
f431733940
@ -56,21 +56,25 @@ class BotManagement(commands.Cog):
|
||||
else:
|
||||
await ctx.send('Rfoo server already stopped')
|
||||
|
||||
def ct(self, coro: Coroutine):
|
||||
def ct(self, coro: Coroutine, timeout=5):
|
||||
"""
|
||||
ct - short from create_task
|
||||
execute coroutine and get result
|
||||
"""
|
||||
|
||||
task = self.bot.loop.create_task(coro)
|
||||
while not task.done():
|
||||
time.sleep(0.1)
|
||||
time.sleep(timeout)
|
||||
|
||||
try:
|
||||
return task.result()
|
||||
|
||||
except asyncio.exceptions.InvalidStateError:
|
||||
return task.exception()
|
||||
exp = task.exception()
|
||||
if exp is None:
|
||||
return task
|
||||
|
||||
else:
|
||||
return exp
|
||||
|
||||
|
||||
async def setup(bot):
|
Loading…
x
Reference in New Issue
Block a user