diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index c9c102c..53a0f0a 100644 --- a/davtelepot/__init__.py +++ b/davtelepot/__init__.py @@ -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.1" +__version__ = "2.8.2" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/davtelepot/bot.py b/davtelepot/bot.py index 05bb975..4e24f40 100644 --- a/davtelepot/bot.py +++ b/davtelepot/bot.py @@ -3438,6 +3438,16 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject): loop.stop() return + @classmethod + async def run_preliminary_tasks(cls): + await asyncio.gather( + *[ + preliminary_task + for bot in cls.bots + for preliminary_task in bot.preliminary_tasks + ] + ) + @classmethod def run(cls, local_host=None, port=None): """Run aiohttp web app and all Bot instances. @@ -3454,15 +3464,7 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject): try: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) - asyncio.run( - asyncio.gather( - *[ - preliminary_task - for bot in cls.bots - for preliminary_task in bot.preliminary_tasks - ] - ) - ) + loop.run_until_complete(cls.run_preliminary_tasks()) except Exception as e: logging.error(f"{e}", exc_info=True) for bot in cls.bots: