Bug fix: no running loop, need to create a new one.

This commit is contained in:
2022-10-12 13:26:03 +02:00
parent 76ea65a660
commit 25abb80343
2 changed files with 5 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0"
__version__ = "2.8.0"
__version__ = "2.8.1"
__maintainer__ = "Davide Testa"
__contact__ = "t.me/davte"

View File

@@ -3469,14 +3469,16 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
bot.setup()
asyncio.ensure_future(cls.start_app())
try:
loop = asyncio.get_running_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_forever()
except KeyboardInterrupt:
logging.info("Stopped by KeyboardInterrupt")
except Exception as e:
logging.error(f"{e}", exc_info=True)
finally:
loop = asyncio.get_running_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(cls.stop_app())
return cls.final_state