Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rth authored and AutomatedTester committed Mar 26, 2019
1 parent 74a36f3 commit e55f355
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions py/selenium/webdriver/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
from selenium.webdriver.common.keys import Keys

try:
# Python 2
basestring
_is_connectable_exceptions = (socket.error,)
except NameError:
# Python 3
basestring = str
_is_connectable_exceptions = (socket.error, ConnectionResetError)


def free_port():
Expand Down Expand Up @@ -102,16 +105,10 @@ 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 expected_exceptions:
except _is_connectable_exceptions:
result = False
finally:
if socket_:
Expand Down

0 comments on commit e55f355

Please sign in to comment.