Skip to content

Commit 6a47cc3

Browse files
committed
[py]: Only SIGKILL service processes that did not gracefully clean up and exit from sigterm
1 parent 18a23ad commit 6a47cc3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

py/selenium/webdriver/common/service.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ def _terminate_process(self) -> None:
167167
except AttributeError:
168168
pass
169169
self.process.terminate()
170-
self.process.wait(60)
171-
# Todo: only SIGKILL if necessary; the process may be cleanly exited by now.
172-
self.process.kill()
170+
try:
171+
self.process.wait(60)
172+
except TimeoutError:
173+
logger.error(
174+
"Service process refused to terminate gracefully with SIGTERM, escalating to SIGKILL.",
175+
exc_info=True,
176+
)
177+
self.process.kill()
173178
except OSError:
174179
logger.error("Error terminating service process.", exc_info=True)
175180

0 commit comments

Comments
 (0)