Stabilize Application.run_* on Python 3.7 (#3009)

This commit is contained in:
Bibo-Joshi 2022-05-10 18:35:20 +02:00 committed by GitHub
parent be8f4f7aad
commit a299867b1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -309,6 +309,10 @@ class Updater(AbstractAsyncContextManager):
pool_timeout=pool_timeout, pool_timeout=pool_timeout,
allowed_updates=allowed_updates, 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: except TelegramError as exc:
# TelegramErrors should be processed by the network retry loop # TelegramErrors should be processed by the network retry loop
raise exc raise exc

View file

@ -18,6 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an abstract class to make POST and GET requests.""" """This module contains an abstract class to make POST and GET requests."""
import abc import abc
import asyncio
from contextlib import AbstractAsyncContextManager from contextlib import AbstractAsyncContextManager
from http import HTTPStatus from http import HTTPStatus
from types import TracebackType from types import TracebackType
@ -275,6 +276,10 @@ class BaseRequest(
connect_timeout=connect_timeout, connect_timeout=connect_timeout,
pool_timeout=pool_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: except TelegramError as exc:
raise exc raise exc
except Exception as exc: except Exception as exc: