Skip to content

Commit c02cf56

Browse files
committed
[py] Use context manager
1 parent b7f21d3 commit c02cf56

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py/selenium/webdriver/common/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ def is_url_connectable(
147147
- scheme - URL scheme
148148
"""
149149
try:
150-
res = urllib.request.urlopen(f"{scheme}://{host}:{port}/status")
151-
return res.getcode() == 200
150+
with urllib.request.urlopen(f"{scheme}://{host}:{port}/status") as res:
151+
return res.getcode() == 200
152152
except Exception:
153153
return False
154154

0 commit comments

Comments
 (0)