Bug fix: use a unique loop
This commit is contained in:
@@ -11,7 +11,7 @@ __author__ = "Davide Testa"
|
|||||||
__email__ = "davide@davte.it"
|
__email__ = "davide@davte.it"
|
||||||
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
||||||
__license__ = "GNU General Public License v3.0"
|
__license__ = "GNU General Public License v3.0"
|
||||||
__version__ = "2.8.2"
|
__version__ = "2.8.3"
|
||||||
__maintainer__ = "Davide Testa"
|
__maintainer__ = "Davide Testa"
|
||||||
__contact__ = "t.me/davte"
|
__contact__ = "t.me/davte"
|
||||||
|
|
||||||
|
|||||||
@@ -3461,9 +3461,9 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
|||||||
cls.local_host = local_host
|
cls.local_host = local_host
|
||||||
if port is not None:
|
if port is not None:
|
||||||
cls.port = port
|
cls.port = port
|
||||||
try:
|
|
||||||
loop = asyncio.new_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
|
try:
|
||||||
loop.run_until_complete(cls.run_preliminary_tasks())
|
loop.run_until_complete(cls.run_preliminary_tasks())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"{e}", exc_info=True)
|
logging.error(f"{e}", exc_info=True)
|
||||||
@@ -3471,16 +3471,12 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
|||||||
bot.setup()
|
bot.setup()
|
||||||
asyncio.ensure_future(cls.start_app())
|
asyncio.ensure_future(cls.start_app())
|
||||||
try:
|
try:
|
||||||
loop = asyncio.new_event_loop()
|
|
||||||
asyncio.set_event_loop(loop)
|
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logging.info("Stopped by KeyboardInterrupt")
|
logging.info("Stopped by KeyboardInterrupt")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"{e}", exc_info=True)
|
logging.error(f"{e}", exc_info=True)
|
||||||
finally:
|
finally:
|
||||||
loop = asyncio.new_event_loop()
|
|
||||||
asyncio.set_event_loop(loop)
|
|
||||||
loop.run_until_complete(cls.stop_app())
|
loop.run_until_complete(cls.stop_app())
|
||||||
return cls.final_state
|
return cls.final_state
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user