diff --git a/telegram/ext/_updater.py b/telegram/ext/_updater.py index 95133d075..536b4f443 100644 --- a/telegram/ext/_updater.py +++ b/telegram/ext/_updater.py @@ -309,6 +309,10 @@ class Updater(AbstractAsyncContextManager): pool_timeout=pool_timeout, allowed_updates=allowed_updates, ) + except asyncio.CancelledError as exc: + # TODO: in py3.8+, CancelledError is a subclass of BaseException, so we can drop + # this clause when we drop py3.7 + raise exc except TelegramError as exc: # TelegramErrors should be processed by the network retry loop raise exc diff --git a/telegram/request/_baserequest.py b/telegram/request/_baserequest.py index 4f83dc5ff..72f71580a 100644 --- a/telegram/request/_baserequest.py +++ b/telegram/request/_baserequest.py @@ -18,6 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains an abstract class to make POST and GET requests.""" import abc +import asyncio from contextlib import AbstractAsyncContextManager from http import HTTPStatus from types import TracebackType @@ -275,6 +276,10 @@ class BaseRequest( connect_timeout=connect_timeout, pool_timeout=pool_timeout, ) + except asyncio.CancelledError as exc: + # TODO: in py3.8+, CancelledError is a subclass of BaseException, so we can drop this + # clause when we drop py3.7 + raise exc except TelegramError as exc: raise exc except Exception as exc: