Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add **connection_pool_kw to Request() constructor #2560

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `naveenvhegde <https://github.com/naveenvhegde>`_
- `neurrone <https://github.com/neurrone>`_
- `NikitaPirate <https://github.com/NikitaPirate>`_
- `Niklas Rosenstein <https://github.com/NiklasRosenstein>`_
- `Nikolai Krivenko <https://github.com/nkrivenko>`_
- `njittam <https://github.com/njittam>`_
- `Noam Meltzer <https://github.com/tsnoam>`_
Expand Down
7 changes: 7 additions & 0 deletions telegram/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__')
Expand All @@ -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 + [
Expand Down Expand Up @@ -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)
Expand Down