From 2c218bfd04a5889ca05ebcf63718c741970ec8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sun, 28 Apr 2019 21:13:19 +0200 Subject: [PATCH] client: Handle server disconnect exceptions. --- pantalaimon/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pantalaimon/client.py b/pantalaimon/client.py index 82413ec..cd50e4d 100644 --- a/pantalaimon/client.py +++ b/pantalaimon/client.py @@ -2,7 +2,8 @@ import asyncio from pprint import pformat from typing import Any, Dict, Optional -from aiohttp.client_exceptions import ClientProxyConnectionError +from aiohttp.client_exceptions import (ClientProxyConnectionError, + ServerDisconnectedError) from nio import (AsyncClient, ClientConfig, EncryptionError, GroupEncryptionError, KeysQueryResponse, MegolmEvent, RoomEncryptedEvent, SyncResponse) @@ -99,7 +100,11 @@ class PanClient(AsyncClient): self._loop_stop() break - except (ClientProxyConnectionError, ConnectionRefusedError): + except ( + ClientProxyConnectionError, + ServerDisconnectedError, + ConnectionRefusedError + ): try: await asyncio.sleep(5) except asyncio.CancelledError: