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'
|
__version__ = '0.2.2'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib2 import urlopen, Request
|
from urllib2 import urlopen, Request, HTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from urllib.request import urlopen, Request
|
from urllib.request import urlopen, Request, HTTPError
|
||||||
|
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
|
@ -323,7 +323,11 @@ def getBestServer(servers):
|
||||||
cum = []
|
cum = []
|
||||||
url = os.path.dirname(server['url'])
|
url = os.path.dirname(server['url'])
|
||||||
for i in range(0, 3):
|
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()
|
start = time.time()
|
||||||
text = uh.read(9)
|
text = uh.read(9)
|
||||||
total = time.time() - start
|
total = time.time() - start
|
||||||
|
|
Loading…
Reference in New Issue