Skip to content

Commit 4eecf04

Browse files
[wptrunner] Fix additional issues with WebDriverProtocol.is_alive() (#46869)
* It's possible for a thread spawned by `WebDriverRun` to outlive the runner process's main thread (https://crbug.com/348266194#comment3), in which case `WebDriverProtocol.is_alive()` may be called after the client is torn down and removed. Tolerate this case. * #22044 didn't actually wire up `HTTPWireProtocol.send(timeout=...)` to the underlying socket timeout.
1 parent c76b65f commit 4eecf04

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tools/webdriver/webdriver/transport.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def send(self,
204204
``json.JSONEncoder`` unless specified.
205205
:param decoder: JSON decoder class, which defaults to
206206
``json.JSONDecoder`` unless specified.
207+
:param timeout: Optional timeout for the underlying socket. `None` will
208+
retain the existing timeout.
207209
:param codec_kwargs: Surplus arguments passed on to `encoder`
208210
and `decoder` on construction.
209211
@@ -231,7 +233,7 @@ def send(self,
231233
# runner thread. We use the boolean below to check for that and restart
232234
# the connection in that case.
233235
self._last_request_is_blocked = True
234-
response = self._request(method, uri, payload, headers, timeout=None)
236+
response = self._request(method, uri, payload, headers, timeout=timeout)
235237
self._last_request_is_blocked = False
236238
return Response.from_http(response, decoder=decoder, **codec_kwargs)
237239

tools/wptrunner/wptrunner/executors/executorwebdriver.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,9 @@ def teardown(self):
509509
self.logger.debug(message)
510510
self.webdriver = None
511511

512-
def is_alive(self):
512+
def is_alive(self) -> bool:
513+
if not self.webdriver:
514+
return False
513515
try:
514516
# Get a simple property over the connection, with 2 seconds of timeout
515517
# that should be more than enough to check if the WebDriver its

0 commit comments

Comments
 (0)