Skip to content

Commit

Permalink
Make TimeoutError message more comprehensive
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Vrachev <[email protected]>
  • Loading branch information
MVrachev committed Oct 1, 2020
1 parent 7f885d2 commit 2693620
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __str__(self):
# but the current blocking connect() seems to work fast on Linux and seems
# to at least work on Windows (ECONNREFUSED unfortunately has a 2 second
# timeout on Windows)
def wait_for_server(host, port, timeout=10):
def wait_for_server(host, server, port, timeout=10):
start = time.time()
remaining_timeout = timeout
succeeded = False
Expand All @@ -77,7 +77,8 @@ def wait_for_server(host, port, timeout=10):
remaining_timeout = timeout - (time.time() - start)

if not succeeded:
raise TimeoutError
raise TimeoutError("Could not connect to the " + server \
+ " on port " + str(port) + " !")


def configure_test_logging(argv):
Expand Down Expand Up @@ -167,10 +168,8 @@ def __init__(self, log, server='simple_server.py',

if timeout > 0:
try:
wait_for_server('localhost', self.port, timeout)
wait_for_server('localhost', self.server, self.port, timeout)
except Exception as e:
self.__logger.error(
"Error while waiting for the server to start: " + repr(e))
# Make sure that errors from the server side will be logged.
self.flush_log()
raise e
Expand Down

0 comments on commit 2693620

Please sign in to comment.