MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / HTTPXRequest

Class HTTPXRequest

src/telegram/request/_httpxrequest.py:41–305  ·  view source on GitHub ↗

Implementation of :class:`~telegram.request.BaseRequest` using the library `httpx `_. .. versionadded:: 20.0 .. versionchanged:: 22.0 Removed the deprecated parameter ``proxy_url``. Use :paramref:`proxy` instead. Args: connection_pool_

Source from the content-addressed store, hash-verified

39
40
41class HTTPXRequest(BaseRequest):
42 """Implementation of :class:`~telegram.request.BaseRequest` using the library
43 `httpx <https://www.python-httpx.org>`_.
44
45 .. versionadded:: 20.0
46
47 .. versionchanged:: 22.0
48 Removed the deprecated parameter ``proxy_url``. Use :paramref:`proxy` instead.
49
50 Args:
51 connection_pool_size (:obj:`int`, optional): Number of connections to keep in the
52 connection pool. Defaults to ``256``.
53
54 .. versionchanged:: 22.4
55 Set the default to ``256``.
56 Stopped applying to ``httpx.Limits.max_keepalive_connections``. Now only applies to
57 ``httpx.Limits.max_connections``. See `Resource Limits
58 <https://www.python-httpx.org/advanced/resource-limits/>`_
59 read_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum
60 amount of time (in seconds) to wait for a response from Telegram&#x27;s server.
61 This value is used unless a different value is passed to :meth:`do_request`.
62 Defaults to ``5``.
63 write_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum
64 amount of time (in seconds) to wait for a write operation to complete (in terms of
65 a network socket; i.e. POSTing a request or uploading a file).
66 This value is used unless a different value is passed to :meth:`do_request`.
67 Defaults to ``5``.
68
69 Hint:
70 This timeout is used for all requests except for those that upload media/files.
71 For the latter, :paramref:`media_write_timeout` is used.
72 connect_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the
73 maximum amount of time (in seconds) to wait for a connection attempt to a server
74 to succeed. This value is used unless a different value is passed to
75 :meth:`do_request`. Defaults to ``5``.
76 pool_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum
77 amount of time (in seconds) to wait for a connection to become available.
78 This value is used unless a different value is passed to :meth:`do_request`.
79 Defaults to ``1``.
80
81 Warning:
82 With a finite pool timeout, you must expect :exc:`telegram.error.TimedOut`
83 exceptions to be thrown when more requests are made simultaneously than there are
84 connections in the connection pool!
85 http_version (:obj:`str`, optional): If ``"2"`` or ``"2.0"``, HTTP/2 will be used instead
86 of HTTP/1.1. Defaults to ``"1.1"``.
87
88 .. versionadded:: 20.1
89 .. versionchanged:: 20.2
90 Reset the default version to 1.1.
91
92 .. versionchanged:: 20.5
93 Accept ``"2"`` as a valid value.
94 socket_options (Collection[:obj:`tuple`], optional): Socket options to be passed to the
95 underlying `library \
96 <https://www.encode.io/httpcore/async/#httpcore.AsyncConnectionPool.__init__>`_.
97
98 Note:

Callers 15

__init__Method · 0.90
_build_requestMethod · 0.90
test_initMethod · 0.90
test_http_2_responseMethod · 0.90
test_slot_behaviourMethod · 0.90
test_httpx_kwargsMethod · 0.90
test_initMethod · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…