Commit e71353a4 authored by Marko Kuder's avatar Marko Kuder

added reload of connection if transactions fail

parent c1e956e1
......@@ -40,9 +40,21 @@ def load_config(ckan_ini_filepath):
config_abs_path = os.path.abspath(ckan_ini_filepath)
conf = paste.deploy.appconfig('config:' + config_abs_path)
import ckan
ckan.config.environment.load_environment(conf.global_conf,
conf.local_conf)
from sqlalchemy.exc import StatementError
from ckan.model.meta import Session
try:
ckan.config.environment.load_environment(conf.global_conf,
conf.local_conf)
except StatementError, se:
log.warning("Statement error in load_config, removing Session to reset it")
log.debug("Full error: "+str(se))
Session.remove()
try:
ckan.config.environment.load_environment(conf.global_conf,
conf.local_conf)
except StatementError, e:
log.error('Statement error in load_config even after dropping Session and retrying: '+str(e))
raise StatementError("Statement error even after dropping Session and retrying: "+str(e))
def register_translator():
# Register a translator in this thread so that
......@@ -441,7 +453,7 @@ def save_qa_result(resource, qa_result, log):
qa = QA.create(resource.id)
model.Session.add(qa)
else:
log.info('QA from before: %r', qa)
log.info(u'QA from before: %r', qa)
for key in ('openness_score', 'openness_score_reason', 'format'):
setattr(qa, key, qa_result[key])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment