From 2af69d982f859581035a89de61ca7ef6639334ee Mon Sep 17 00:00:00 2001 From: andrei_borisevich Date: Sun, 25 Aug 2024 15:06:00 +0300 Subject: [PATCH] Fixed timeout argument in Transport Signed-off-by: Andrei Borisevich --- opensearchpy/transport.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/opensearchpy/transport.py b/opensearchpy/transport.py index 2385b2b8..5ec6d134 100644 --- a/opensearchpy/transport.py +++ b/opensearchpy/transport.py @@ -404,9 +404,11 @@ def perform_request( underlying :class:`~opensearchpy.Connection` class for serialization :arg body: body of the request, will be serialized using serializer and passed to the connection + :arg timeout: timeout of the request. If it is not presented as argument + will be extracted from `params` """ method, params, body, ignore, timeout = self._resolve_request_args( - method, params, body + method, params, body, timeout ) for attempt in range(self.max_retries + 1): @@ -473,7 +475,13 @@ def close(self) -> Any: """ return self.connection_pool.close() - def _resolve_request_args(self, method: str, params: Any, body: Any) -> Any: + def _resolve_request_args( + self, + method: str, + params: Any, + body: Any, + timeout: Optional[Union[int, float]], + ) -> Any: """Resolves parameters for .perform_request()""" if body is not None: body = self.serializer.dumps(body) @@ -499,11 +507,9 @@ def _resolve_request_args(self, method: str, params: Any, body: Any) -> Any: pass ignore = () - timeout = None if params: - timeout = params.pop("request_timeout", None) if not timeout: - timeout = params.pop("timeout", None) + timeout = params.pop("request_timeout", None) or params.pop("timeout", None) ignore = params.pop("ignore", ()) if isinstance(ignore, int): ignore = (ignore,)