Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/31.canada.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handled database timeout exceptions to close temporary files.
18 changes: 16 additions & 2 deletions ckanext/xloader/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ def tabulator_load():
# (canada fork only): adds in encoding argument to pass static/resource encoding
encoding=validation_options.get('encoding', None),
logger=logger)
except errors.QueryCanceled as e: # (canada fork only): handle db timeouts
# (canada fork only): always close tmp file on exceptions
#TODO: upstream contrib??
tmp_file.close()
logger.warning('XLoader job ran into a database query timeout')
raise JobError('XLoader job ran into a database query timeout')
except rq_timeouts.JobTimeoutException as e: # (canada fork only): handle rq timeouts
# (canada fork only): always close tmp file on exceptions
#TODO: upstream contrib??
Expand Down Expand Up @@ -286,6 +292,12 @@ def tabulator_load():
else:
try:
direct_load()
except errors.QueryCanceled as e: # (canada fork only): handle db timeouts
# (canada fork only): always close tmp file on exceptions
#TODO: upstream contrib??
tmp_file.close()
logger.warning('XLoader job ran into a database query timeout')
raise JobError('XLoader job ran into a database query timeout')
except rq_timeouts.JobTimeoutException as e: # (canada fork only): handle rq timeouts
# (canada fork only): always close tmp file on exceptions
#TODO: upstream contrib??
Expand Down Expand Up @@ -314,8 +326,10 @@ def tabulator_load():
logger.warning('Loading excerpt for this format not supported.')
logger.error('Loading file raised an error: %s', e)
raise JobError('Loading file raised an error: {}'.format(e))

tmp_file.close()
finally:
# (canada fork only): put close into finally
# TODO: upstream contribution??
tmp_file.close()

logger.info('Express Load completed')

Expand Down
Loading