Skip to content

Commit

Permalink
Fixed timeout argument in Transport
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Borisevich <andreyborisevichleti@gmail.com>
  • Loading branch information
aborisevichcl committed Aug 25, 2024
1 parent 7171224 commit 2af69d9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions opensearchpy/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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,)
Expand Down

0 comments on commit 2af69d9

Please sign in to comment.