data_source_plugin: report timeout errors details
This commit is contained in:
parent
42bd357c96
commit
117952da4c
|
@ -11,7 +11,7 @@ from django.template import Template
|
||||||
|
|
||||||
import feedparser
|
import feedparser
|
||||||
import requests
|
import requests
|
||||||
from requests.exceptions import RequestException, HTTPError
|
from requests.exceptions import RequestException, HTTPError, Timeout
|
||||||
|
|
||||||
from cms.plugin_base import CMSPluginBase
|
from cms.plugin_base import CMSPluginBase
|
||||||
from cms.plugin_pool import plugin_pool
|
from cms.plugin_pool import plugin_pool
|
||||||
|
@ -45,6 +45,7 @@ class Data(object):
|
||||||
|
|
||||||
|
|
||||||
def update_content(self):
|
def update_content(self):
|
||||||
|
content = None
|
||||||
try:
|
try:
|
||||||
self.final_url = self.url
|
self.final_url = self.url
|
||||||
if self.data_source.signature_key:
|
if self.data_source.signature_key:
|
||||||
|
@ -64,20 +65,20 @@ class Data(object):
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
logger.warning('HTTP Error %s when loading datasource %s from'
|
logger.warning('HTTP Error %s when loading datasource %s from'
|
||||||
' URL %s', request.status_code, self.data_source.id, self.final_url)
|
' URL %s', request.status_code, self.data_source.id, self.final_url)
|
||||||
content = None
|
except Timeout:
|
||||||
|
logger.warning('HTTP Request timeout(%s s) when loading datasource'
|
||||||
|
' %s from URL %s', self.data_source.timeout,
|
||||||
|
self.data_source.id, self.final_url)
|
||||||
except RequestException:
|
except RequestException:
|
||||||
logger.warning('HTTP Request failed when loading datasource'
|
logger.warning('HTTP Request failed when loading datasource'
|
||||||
' %s from URL %s', self.data_source.id, self.final_url)
|
' %s from URL %s', self.data_source.id, self.final_url)
|
||||||
content = None
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Unkown exception when loading datasource %s'
|
logger.exception('Unkown exception when loading datasource %s'
|
||||||
' from URL %s', self.data_source.id, self.final_url)
|
' from URL %s', self.data_source.id, self.final_url)
|
||||||
content = None
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
content = getattr(self, 'get_content_'+self.kind)(request)
|
content = getattr(self, 'get_content_'+self.kind)(request)
|
||||||
except Exception:
|
except Exception:
|
||||||
content = None
|
|
||||||
logger.exception('decoding of content from %s failed', self.final_url)
|
logger.exception('decoding of content from %s failed', self.final_url)
|
||||||
else:
|
else:
|
||||||
logger.debug('getting data source %r from url %r finished',
|
logger.debug('getting data source %r from url %r finished',
|
||||||
|
|
Reference in New Issue