Handle 404 for latency.txt requests, Fixes #27
This commit is contained in:
parent
f679e76ff4
commit
79aeabe4e7
|
@ -18,9 +18,9 @@
|
|||
__version__ = '0.2.2'
|
||||
|
||||
try:
|
||||
from urllib2 import urlopen, Request
|
||||
from urllib2 import urlopen, Request, HTTPError
|
||||
except ImportError:
|
||||
from urllib.request import urlopen, Request
|
||||
from urllib.request import urlopen, Request, HTTPError
|
||||
|
||||
import math
|
||||
import time
|
||||
|
@ -323,7 +323,11 @@ def getBestServer(servers):
|
|||
cum = []
|
||||
url = os.path.dirname(server['url'])
|
||||
for i in range(0, 3):
|
||||
uh = urlopen('%s/latency.txt' % url)
|
||||
try:
|
||||
uh = urlopen('%s/latency.txt' % url)
|
||||
except HTTPError:
|
||||
cum.append(3600)
|
||||
continue
|
||||
start = time.time()
|
||||
text = uh.read(9)
|
||||
total = time.time() - start
|
||||
|
|
Loading…
Reference in New Issue