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

Fixed timeout argument in Transport #808

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading