[py] service: only shutdown if process not terminated #15183
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
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.
Motivation and Context
Fixes #15182
Types of changes
Checklist
PR Type
Bug fix
Description
Added a check to ensure the service process has not terminated before sending a shutdown command.
Prevented redundant shutdown attempts when
stop()
is called multiple times.Improved robustness of the
stop()
method in theService
class.Changes walkthrough 📝
service.py
Added process termination check in `stop()` method
py/selenium/webdriver/common/service.py
using
poll()
.terminated.