From 8da1fb78b846deb186cf68d4de66502d51e20881 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 21 Oct 2018 00:09:37 +0300 Subject: [PATCH] Handle aiohttp errors in syncer. Fixes #210 --- mautrix_telegram/puppet.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mautrix_telegram/puppet.py b/mautrix_telegram/puppet.py index 6b28e850..5d6f76d5 100644 --- a/mautrix_telegram/puppet.py +++ b/mautrix_telegram/puppet.py @@ -16,10 +16,11 @@ # along with this program. If not, see . from typing import Awaitable, Coroutine, Dict, List, Optional, Pattern, TYPE_CHECKING from difflib import SequenceMatcher -import re -import logging -import asyncio from enum import Enum +from aiohttp import ServerDisconnectedError +import asyncio +import logging +import re from sqlalchemy import orm @@ -250,7 +251,7 @@ class Puppet: } # type: Dict self.handle_sync(presence, ephemeral) next_batch = sync_resp.get("next_batch", None) - except MatrixRequestError as e: + except (MatrixRequestError, ServerDisconnectedError) as e: wait = min(errors, 11) ** 2 self.log.warning(f"Syncer for {custom_mxid} errored: {e}. " f"Waiting for {wait} seconds...")