Эх сурвалжийг харах

Retry forever when refresh fails for unknown reason

Tulir Asokan 3 жил өмнө
parent
commit
2cb9e9f830

+ 8 - 4
mautrix_instagram/user.py

@@ -319,6 +319,7 @@ class User(DBUser, BaseUser):
             await self.stop_listen()
             await self.stop_listen()
             if resync:
             if resync:
                 retry_count = 0
                 retry_count = 0
+                minutes = 1
                 while True:
                 while True:
                     try:
                     try:
                         await self.sync()
                         await self.sync()
@@ -327,12 +328,15 @@ class User(DBUser, BaseUser):
                         self.log.exception("Got not logged in error while syncing for refresh")
                         self.log.exception("Got not logged in error while syncing for refresh")
                         await self.logout(error=e)
                         await self.logout(error=e)
                     except Exception:
                     except Exception:
-                        if retry_count >= 4:
-                            raise
+                        if retry_count >= 4 and minutes < 5:
+                            minutes += 1
                         retry_count += 1
                         retry_count += 1
-                        self.log.exception("Error while syncing for refresh, retrying in 1 minute")
+                        s = "s" if minutes != 1 else ""
+                        self.log.exception(
+                            f"Error while syncing for refresh, retrying in {minutes} minute{s}"
+                        )
                         await self.push_bridge_state(BridgeStateEvent.UNKNOWN_ERROR)
                         await self.push_bridge_state(BridgeStateEvent.UNKNOWN_ERROR)
-                        await asyncio.sleep(60)
+                        await asyncio.sleep(minutes * 60)
             else:
             else:
                 await self.start_listen()
                 await self.start_listen()
         finally:
         finally: