Skip to content

Commit

Permalink
enh: improve logging in background job
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 22, 2024
1 parent d30352e commit 4d18366
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.15.4
- enh: improve logging in background job
0.15.3
- fix: do not use unreliable tempfile.TemporaryDirectory
- setup: bump dclab to 0.58.3 (LazyContourList has max_events)
Expand Down
8 changes: 7 additions & 1 deletion ckanext/dc_serve/jobs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import pathlib
import tempfile
import traceback
import warnings

import ckan.plugins.toolkit as toolkit
Expand All @@ -13,13 +15,17 @@
from .res_file_lock import CKANResourceFileLock


log = logging.getLogger(__name__)


def admin_context():
return {'ignore_auth': True, 'user': 'default'}


def generate_condensed_resource_job(resource, override=False):
"""Generates a condensed version of the dataset"""
rid = resource["id"]
log.info(f"Generating condensed resource {rid}")
wait_for_resource(rid)
mtype = resource.get('mimetype', '')
if (mtype in DC_MIME_TYPES
Expand Down Expand Up @@ -127,7 +133,7 @@ def generate_condensed_resource_job(resource, override=False):
override=True)
return True
except BaseException:
pass
log.error(traceback.format_exc())
finally:
path_cond.unlink(missing_ok=True)
return False

0 comments on commit 4d18366

Please sign in to comment.