Skip to content

Commit d9fe0be

Browse files
authored
Report wait time of failed wait for test socket server (#930)
1 parent 8fec7ee commit d9fe0be

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

Tests/modules/network_related/test__socket.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,18 +426,21 @@ def server_thread():
426426

427427
_thread.start_new_thread(server_thread, ())
428428
#Give the server a chance to startup
429-
for _ in range(10):
429+
portex = None
430+
startTime = time.perf_counter()
431+
for _ in range(20):
430432
time.sleep(1)
431433
if EXIT_CODE > 0:
432434
self.fail("Server died with exit code %d" % EXIT_CODE)
433435
try:
434436
with open(portFile) as f:
435437
PORT = int(f.read())
436438
break
437-
except:
438-
pass
439+
except Exception as ex:
440+
portex = ex
439441
else:
440-
self.fail("Server not detected")
442+
duration = time.perf_counter() - startTime
443+
self.fail("Server not detected after trying for %g s, last detection attempt resulted in %r" % (duration, portex))
441444

442445
#Client
443446
HOST = 'localhost'
@@ -562,18 +565,21 @@ def server_thread():
562565

563566
_thread.start_new_thread(server_thread, ())
564567
#Give the server a chance to startup
565-
for _ in range(10):
568+
portex = None
569+
startTime = time.perf_counter()
570+
for _ in range(20):
566571
time.sleep(1)
567572
if EXIT_CODE > 0:
568573
self.fail("Server died with exit code %d" % EXIT_CODE)
569574
try:
570575
with open(portFile) as f:
571576
PORT = int(f.read())
572577
break
573-
except:
574-
pass
578+
except Exception as ex:
579+
portex = ex
575580
else:
576-
self.fail("Server not detected")
581+
duration = time.perf_counter() - startTime
582+
self.fail("Server not detected after trying for %g s, last detection attempt resulted in %r" % (duration, portex))
577583

578584
#Client
579585
HOST = 'localhost'

0 commit comments

Comments
 (0)