Skip to content

Commit

Permalink
service: only shutdown if process not terminated
Browse files Browse the repository at this point in the history
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 SeleniumHQ#15182

Signed-off-by: Sandro Pischinger <[email protected]>
  • Loading branch information
PSandro committed Jan 29, 2025
1 parent 5c78d24 commit 1eb1fbd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def stop(self) -> None:
elif isinstance(self.log_output, int):
os.close(self.log_output)

if self.process is not None:
if self.process is not None and self.process.poll() is None:
try:
self.send_remote_shutdown_command()
except TypeError:
Expand Down

0 comments on commit 1eb1fbd

Please sign in to comment.