Add config option to exit if telethon update loop fails
This commit is contained in:
@@ -228,9 +228,20 @@ class AbstractUser(ABC):
|
|||||||
sequential_updates=self.config["telegram.sequential_updates"],
|
sequential_updates=self.config["telegram.sequential_updates"],
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
base_logger=base_logger,
|
base_logger=base_logger,
|
||||||
|
update_error_callback=self._telethon_update_error_callback,
|
||||||
)
|
)
|
||||||
self.client.add_event_handler(self._update_catch)
|
self.client.add_event_handler(self._update_catch)
|
||||||
|
|
||||||
|
async def _telethon_update_error_callback(self, err: Exception) -> None:
|
||||||
|
if self.config["telegram.exit_on_update_error"]:
|
||||||
|
self.log.critical(f"Stopping due to update handling error {type(err).__name__}")
|
||||||
|
self.bridge.manual_stop(50)
|
||||||
|
else:
|
||||||
|
self.log.info("Recreating Telethon update loop in 60 seconds")
|
||||||
|
await asyncio.sleep(60)
|
||||||
|
self.log.debug("Now recreating Telethon update loop")
|
||||||
|
self.client._updates_handle = self.loop.create_task(self.client._update_loop())
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def update(self, update: TypeUpdate) -> bool:
|
async def update(self, update: TypeUpdate) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ class Config(BaseBridgeConfig):
|
|||||||
|
|
||||||
copy("telegram.catch_up")
|
copy("telegram.catch_up")
|
||||||
copy("telegram.sequential_updates")
|
copy("telegram.sequential_updates")
|
||||||
|
copy("telegram.exit_on_update_error")
|
||||||
|
|
||||||
copy("telegram.connection.timeout")
|
copy("telegram.connection.timeout")
|
||||||
copy("telegram.connection.retries")
|
copy("telegram.connection.retries")
|
||||||
|
|||||||
@@ -459,6 +459,7 @@ telegram:
|
|||||||
catch_up: true
|
catch_up: true
|
||||||
# Should incoming updates be handled sequentially to make sure order is preserved on Matrix?
|
# Should incoming updates be handled sequentially to make sure order is preserved on Matrix?
|
||||||
sequential_updates: true
|
sequential_updates: true
|
||||||
|
exit_on_update_error: false
|
||||||
|
|
||||||
# Telethon connection options.
|
# Telethon connection options.
|
||||||
connection:
|
connection:
|
||||||
|
|||||||
+2
-2
@@ -3,9 +3,9 @@ python-magic>=0.4,<0.5
|
|||||||
commonmark>=0.8,<0.10
|
commonmark>=0.8,<0.10
|
||||||
aiohttp>=3,<4
|
aiohttp>=3,<4
|
||||||
yarl>=1,<2
|
yarl>=1,<2
|
||||||
mautrix>=0.16.4,<0.17
|
mautrix>=0.16.5,<0.17
|
||||||
#telethon>=1.24,<1.25
|
#telethon>=1.24,<1.25
|
||||||
tulir-telethon==1.25.0a14
|
tulir-telethon==1.25.0a15
|
||||||
asyncpg>=0.20,<0.26
|
asyncpg>=0.20,<0.26
|
||||||
mako>=1,<2
|
mako>=1,<2
|
||||||
setuptools
|
setuptools
|
||||||
|
|||||||
Reference in New Issue
Block a user