From 0e75a79540f8dcf6b172b732f84bef70eea74518 Mon Sep 17 00:00:00 2001 From: Robin <167366979+allrob23@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:00:15 -0300 Subject: [PATCH] fix: add socket.shutdown() before close() to ensure timely closing --- py/selenium/webdriver/common/utils.py | 4 ++++ 1 file changed, 4 insertions(+) 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