Skip to content

Commit 1eb1fbd

Browse files
committed
service: only shutdown if process not terminated
There are scenarios where a stop() is called on a Service object multiple times. This also happens when explicitly quitting a Webdriver using driver.quit() and afterwards having the garbage collector destroy the service object, calling stop() another time even though the service process has already terminated. The check inside the stop() call only ensured that the process variable is not None, but ignored the fact that the process might already have terminated. Therefor an additional check is introduced to only send the remote shutdown command if the service process has not ended. Fixes #15182 Signed-off-by: Sandro Pischinger <[email protected]>
1 parent 5c78d24 commit 1eb1fbd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/selenium/webdriver/common/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def stop(self) -> None:
152152
elif isinstance(self.log_output, int):
153153
os.close(self.log_output)
154154

155-
if self.process is not None:
155+
if self.process is not None and self.process.poll() is None:
156156
try:
157157
self.send_remote_shutdown_command()
158158
except TypeError:

0 commit comments

Comments
 (0)