Skip to content

Commit edcb761

Browse files
committed
Add docstring to __del__ method in Service class for clarity on cleanup behavior
1 parent 0f20ace commit edcb761

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

py/selenium/webdriver/common/service.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ def _terminate_process(self) -> None:
190190
logger.error("Error terminating service process.", exc_info=True)
191191

192192
def __del__(self) -> None:
193+
"""Cleanup and terminate the service process when the object is destroyed.
194+
195+
Attempts to gracefully stop the service process when the instance is
196+
garbage collected. `subprocess.Popen` doesn't send signals on `__del__`,
197+
so we explicitly call stop() here. Note: globals are not referenced here
198+
as they may be None during interpreter shutdown.
199+
"""
193200
# `subprocess.Popen` doesn't send signal on `__del__`;
194201
# so we attempt to close the launched process when `__del__`
195202
# is triggered.

0 commit comments

Comments
 (0)