From b4e7b9324b429a53f8d06b7de16260b196d75992 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 5 Feb 2014 17:29:15 -0500 Subject: [PATCH] Fixed listener stats thread hanging on network errors * Same fix as before, urlopen() wasn't being used with a timeout. * Fixes CC-5472 and SAAS-394 aka. listener stats breaking all the time --- python_apps/pypo/listenerstat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python_apps/pypo/listenerstat.py b/python_apps/pypo/listenerstat.py index 10d9359fd..da6c23880 100644 --- a/python_apps/pypo/listenerstat.py +++ b/python_apps/pypo/listenerstat.py @@ -10,6 +10,8 @@ import time from api_clients import api_client class ListenerStat(Thread): + HTTP_REQUEST_TIMEOUT = 30 # 30 second HTTP request timeout + def __init__(self, logger=None): Thread.__init__(self) self.api_client = api_client.AirtimeApiClient() @@ -46,7 +48,7 @@ class ListenerStat(Thread): url=url, headers=header) - f = urllib2.urlopen(req) + f = urllib2.urlopen(req, timeout=ListenerStat.HTTP_REQUEST_TIMEOUT) document = f.read() return document