mirror of
https://github.com/sivel/speedtest-cli.git
synced 2026-10-22 10:36:26 +02:00
Catch scenario where no servers could be connected to for latency tests
This commit is contained in:
+9
-1
@@ -262,6 +262,10 @@ class SpeedtestUploadTimeout(SpeedtestException):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class SpeedtestBestServerFailure(SpeedtestException):
|
||||||
|
"""Unable to determine best server"""
|
||||||
|
|
||||||
|
|
||||||
def bound_socket(*args, **kwargs):
|
def bound_socket(*args, **kwargs):
|
||||||
"""Bind socket to a specified source IP address"""
|
"""Bind socket to a specified source IP address"""
|
||||||
|
|
||||||
@@ -912,7 +916,11 @@ class Speedtest(object):
|
|||||||
avg = round((sum(cum) / 6) * 1000.0, 3)
|
avg = round((sum(cum) / 6) * 1000.0, 3)
|
||||||
results[avg] = server
|
results[avg] = server
|
||||||
|
|
||||||
fastest = sorted(results.keys())[0]
|
try:
|
||||||
|
fastest = sorted(results.keys())[0]
|
||||||
|
except IndexError:
|
||||||
|
raise SpeedtestBestServerFailure('Unable to connect to servers to '
|
||||||
|
'test latency.')
|
||||||
best = results[fastest]
|
best = results[fastest]
|
||||||
best['latency'] = fastest
|
best['latency'] = fastest
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user