mirror of
https://github.com/sivel/speedtest-cli.git
synced 2026-08-04 06:40:52 +00:00
Catch scenario where no servers could be connected to for latency tests
This commit is contained in:
parent
2be4d0a5e7
commit
b075152e3e
1 changed files with 9 additions and 1 deletions
10
speedtest.py
10
speedtest.py
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue