diff --git a/py/selenium/webdriver/common/utils.py b/py/selenium/webdriver/common/utils.py index 6b63b9ff4cb08..375838aceb757 100644 --- a/py/selenium/webdriver/common/utils.py +++ b/py/selenium/webdriver/common/utils.py @@ -104,6 +104,10 @@ def is_connectable(port: int, host: Optional[str] = "localhost") -> bool: result = False finally: if socket_: + try: + socket_.shutdown(socket.SHUT_RDWR) + except: + pass socket_.close() return result