1
0
mirror of https://github.com/GOSTSec/gostcoin.i2p synced 2025-02-06 11:54:15 +00:00

add timeout to script

This commit is contained in:
R4SAS 2017-11-07 11:06:13 +03:00
parent 6582dc6ffa
commit 3312d1e511

View File

@ -31,13 +31,14 @@ THUMB_DPI = 40 # thumbnail DPI
DPI = 120 # affects the size of output image DPI = 120 # affects the size of output image
PROXY_URL = 'http://localhost:4444' PROXY_URL = 'http://localhost:4444'
TIMEOUT = 30
def get_data_from_nvspc(url): def get_data_from_nvspc(url):
proxy_handler = urllib.request.ProxyHandler({ proxy_handler = urllib.request.ProxyHandler({
'http': PROXY_URL 'http': PROXY_URL
}) })
opener = urllib.request.build_opener(proxy_handler) opener = urllib.request.build_opener(proxy_handler)
response = opener.open(url) response = opener.open(url, None, TIMEOUT)
raw_result = response.read().decode() raw_result = response.read().decode()
data = reversed(json.loads(raw_result)['data']['l']) data = reversed(json.loads(raw_result)['data']['l'])
return data return data