mirror of
https://github.com/sivel/speedtest-cli.git
synced 2026-10-02 17:06:11 +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):
|
||||
"""Bind socket to a specified source IP address"""
|
||||
|
||||
@@ -912,7 +916,11 @@ class Speedtest(object):
|
||||
avg = round((sum(cum) / 6) * 1000.0, 3)
|
||||
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['latency'] = fastest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user