From 3312d1e5114420f83022b89093f6057c3b259fa9 Mon Sep 17 00:00:00 2001 From: r4sas Date: Tue, 7 Nov 2017 11:06:13 +0300 Subject: [PATCH] add timeout to script --- scripts/plot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/plot.py b/scripts/plot.py index 2197adc..288c487 100755 --- a/scripts/plot.py +++ b/scripts/plot.py @@ -31,13 +31,14 @@ THUMB_DPI = 40 # thumbnail DPI DPI = 120 # affects the size of output image PROXY_URL = 'http://localhost:4444' +TIMEOUT = 30 def get_data_from_nvspc(url): proxy_handler = urllib.request.ProxyHandler({ 'http': PROXY_URL }) opener = urllib.request.build_opener(proxy_handler) - response = opener.open(url) + response = opener.open(url, None, TIMEOUT) raw_result = response.read().decode() data = reversed(json.loads(raw_result)['data']['l']) return data