Skip to content

Commit

Permalink
Handle Python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rth authored and AutomatedTester committed Mar 26, 2019
1 parent a333690 commit 74a36f3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion py/selenium/webdriver/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ def is_connectable(port, host="localhost"):
- port - The port to connect.
"""
socket_ = None

if sys.version_info > (3, 4):
expected_exceptions = (socket.error, ConnectionResetError)
else:
expected_exceptions = (socket.error,)

try:
socket_ = socket.create_connection((host, port), 1)
result = True
except (socket.error, ConnectionResetError) as e:
except expected_exceptions:
result = False
finally:
if socket_:
Expand Down

0 comments on commit 74a36f3

Please sign in to comment.