Skip to content

Commit

Permalink
fix(logic): try/catch;
Browse files Browse the repository at this point in the history
- No alias import to fix try/catch.
  • Loading branch information
JVickery-TBS committed Dec 9, 2024
1 parent 775fb83 commit ee5f621
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ckanext/xloader/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from psycopg2 import errors
from six.moves.urllib.parse import urlsplit
import requests
from rq import get_current_job, timeouts as rq_timeouts
from rq import get_current_job
from rq.timeouts import JobTimeoutException
import sqlalchemy as sa

from ckan import model
Expand Down Expand Up @@ -259,8 +260,11 @@ def tabulator_load():
logger.warning('Load using COPY failed: %s', e)
logger.info('Trying again with tabulator')
tabulator_load()
except rq_timeouts.JobTimeoutException as e:
tmp_file.close()
except JobTimeoutException as e:
try:
tmp_file.close()
except FileNotFoundError:
pass
timeout = config.get('ckanext.xloader.job_timeout', '3600')
logger.warning('Job time out after %ss', timeout)
raise JobError('Job timed out after {}s'.format(timeout))
Expand Down Expand Up @@ -383,7 +387,7 @@ def _download_resource_data(resource, data, api_key, logger):
raise HTTPError(
message=err_message, status_code=None,
request_url=url, response=None)
except rq_timeouts.JobTimeoutException as e:
except JobTimeoutException as e:
tmp_file.close()
timeout = config.get('ckanext.xloader.job_timeout', '3600')
logger.warning('Job time out after %ss', timeout)
Expand Down

0 comments on commit ee5f621

Please sign in to comment.