diff --git a/AUTHORS.rst b/AUTHORS.rst index 2b3f26e415f..962417a8744 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -77,6 +77,7 @@ The following wonderful people contributed directly or indirectly to this projec - `naveenvhegde `_ - `neurrone `_ - `NikitaPirate `_ +- `Niklas Rosenstein `_ - `Nikolai Krivenko `_ - `njittam `_ - `Noam Meltzer `_ diff --git a/telegram/utils/request.py b/telegram/utils/request.py index f2c35bfdffc..02da77c8ef6 100644 --- a/telegram/utils/request.py +++ b/telegram/utils/request.py @@ -109,7 +109,9 @@ class Request: between consecutive read operations for a response from the server. :obj:`None` will set an infinite timeout. This value is usually overridden by the various :class:`telegram.Bot` methods. Defaults to ``5.0``. + connection_pool_kw: Additional keyword arguments to pass to the underlying connection pool. + .. versionadded:: 13.6.1 """ __slots__ = ('_connect_timeout', '_con_pool_size', '_con_pool', '__dict__') @@ -121,10 +123,14 @@ def __init__( urllib3_proxy_kwargs: JSONDict = None, connect_timeout: float = 5.0, read_timeout: float = 5.0, + connection_pool_kw: JSONDict = None, ): if urllib3_proxy_kwargs is None: urllib3_proxy_kwargs = {} + if connection_pool_kw is None: + connection_pool_kw = {} + self._connect_timeout = connect_timeout sockopts = HTTPConnection.default_socket_options + [ @@ -152,6 +158,7 @@ def __init__( socket_options=sockopts, timeout=urllib3.Timeout(connect=self._connect_timeout, read=read_timeout, total=None), ) + kwargs.update(connection_pool_kw) # Set a proxy according to the following order: # * proxy defined in proxy_url (+ urllib3_proxy_kwargs)