From a0a2976e0ab3f22b91563bf0dc76de1f6c7061ed Mon Sep 17 00:00:00 2001 From: Michael H Date: Sat, 2 Jun 2018 18:43:26 -0400 Subject: [PATCH] [V3] Fixes issue preventing token reset from setup (#1771) * fixes issue preventing token reset. Also removes a faulty assumption about not needing cleanup tasks * Update __main__.py remove unneeded condition --- redbot/__main__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/redbot/__main__.py b/redbot/__main__.py index ad28cb38334..e12fcc8917f 100644 --- a/redbot/__main__.py +++ b/redbot/__main__.py @@ -139,18 +139,16 @@ def main(): sys.exit(0) if tmp_data["enable_sentry"]: red.enable_sentry() - cleanup_tasks = True try: loop.run_until_complete(red.start(token, bot=not cli_flags.not_bot)) except discord.LoginFailure: - cleanup_tasks = False # No login happened, no need for this log.critical( "This token doesn't seem to be valid. If it belongs to " "a user account, remember that the --not-bot flag " "must be used. For self-bot functionalities instead, " "--self-bot" ) - db_token = red.db.token() + db_token = loop.run_until_complete(red.db.token()) if db_token and not cli_flags.no_prompt: print("\nDo you want to reset the token? (y/n)") if confirm("> "): @@ -165,10 +163,9 @@ def main(): sentry_log.critical("Fatal Exception", exc_info=e) loop.run_until_complete(red.logout()) finally: - if cleanup_tasks: - pending = asyncio.Task.all_tasks(loop=red.loop) - gathered = asyncio.gather(*pending, loop=red.loop, return_exceptions=True) - gathered.cancel() + pending = asyncio.Task.all_tasks(loop=red.loop) + gathered = asyncio.gather(*pending, loop=red.loop, return_exceptions=True) + gathered.cancel() sys.exit(red._shutdown_mode.value)