Skip to content

Commit

Permalink
[py] Remote connection use timeout from ClientConfig (#14692)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Oct 31, 2024
1 parent 961db5e commit e9ec0be
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion py/selenium/webdriver/chromium/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def __init__(
ignore_proxy: Optional[bool] = False,
client_config: Optional[ClientConfig] = None,
) -> None:
client_config = client_config or ClientConfig(remote_server_addr=remote_server_addr, keep_alive=keep_alive)
client_config = client_config or ClientConfig(
remote_server_addr=remote_server_addr, keep_alive=keep_alive, timeout=120
)
super().__init__(
ignore_proxy=ignore_proxy,
client_config=client_config,
Expand Down
4 changes: 3 additions & 1 deletion py/selenium/webdriver/firefox/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __init__(
ignore_proxy: Optional[bool] = False,
client_config: Optional[ClientConfig] = None,
) -> None:
client_config = client_config or ClientConfig(remote_server_addr=remote_server_addr, keep_alive=keep_alive)
client_config = client_config or ClientConfig(
remote_server_addr=remote_server_addr, keep_alive=keep_alive, timeout=120
)
super().__init__(
ignore_proxy=ignore_proxy,
client_config=client_config,
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/ie/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
self.service.start()

client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive)
client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
executor = RemoteConnection(
ignore_proxy=options._ignore_local_proxy,
client_config=client_config,
Expand Down
6 changes: 3 additions & 3 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def execute(self, command, params):
LOGGER.debug("%s %s %s", command_info[0], url, str(trimmed))
return self._request(command_info[0], url, body=data)

def _request(self, method, url, body=None, timeout=120):
def _request(self, method, url, body=None):
"""Send an HTTP request to the remote server.
:Args:
Expand All @@ -397,12 +397,12 @@ def _request(self, method, url, body=None, timeout=120):
body = None

if self._client_config.keep_alive:
response = self._conn.request(method, url, body=body, headers=headers, timeout=timeout)
response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
statuscode = response.status
else:
conn = self._get_connection_manager()
with conn as http:
response = http.request(method, url, body=body, headers=headers, timeout=timeout)
response = http.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
statuscode = response.status
data = response.data.decode("UTF-8")
LOGGER.debug("Remote response: status=%s | data=%s | headers=%s", response.status, data, response.headers)
Expand Down
4 changes: 3 additions & 1 deletion py/selenium/webdriver/safari/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __init__(
ignore_proxy: Optional[bool] = False,
client_config: Optional[ClientConfig] = None,
) -> None:
client_config = client_config or ClientConfig(remote_server_addr=remote_server_addr, keep_alive=keep_alive)
client_config = client_config or ClientConfig(
remote_server_addr=remote_server_addr, keep_alive=keep_alive, timeout=120
)
super().__init__(
ignore_proxy=ignore_proxy,
client_config=client_config,
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/safari/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
if not self.service.reuse_service:
self.service.start()

client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive)
client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
executor = SafariRemoteConnection(
ignore_proxy=options._ignore_local_proxy,
client_config=client_config,
Expand Down

0 comments on commit e9ec0be

Please sign in to comment.