Skip to content

Commit

Permalink
enh: prioritize ETag computation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 25, 2024
1 parent 40900e3 commit 6e14632
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.20.6
- ref: enqueue eTag retrieval "at front"
- ref: introduce `IS_BACKGROUND_JOB` as workaround to prevent background
jobs to enqueue other background jobs via `after_dataset_update`
- ref: other code cleanup
0.20.5
- fix: avoid excessive API calls in auth.package_update (performance)
- ref: remove unused and broken plugin..after_resource_update
Expand Down
10 changes: 6 additions & 4 deletions ckanext/dcor_schemas/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import copy
import datetime
import mimetypes
import pathlib
import sys
Expand All @@ -12,7 +11,7 @@
import ckan.plugins.toolkit as toolkit

import dclab
from dcor_shared import DC_MIME_TYPES, get_ckan_config_option
from dcor_shared import DC_MIME_TYPES
from rq.job import Job


Expand All @@ -28,6 +27,8 @@
# This is used for job testing. Set it to True if you need concurrent
# background jobs and are using resource_create and the likes.
DISABLE_AFTER_DATASET_CREATE_FOR_CONCURRENT_JOB_TESTS = False
# Used for disabling `after_resource_create` in background jobs
IS_BACKGROUND_JOB = bool(" ".join(sys.argv).count("jobs worker"))

#: ignored schema fields (see default_create_package_schema in
#: https://github.com/ckan/ckan/blob/master/ckan/logic/schema.py)
Expand Down Expand Up @@ -355,7 +356,8 @@ def after_dataset_update(self, context, data_dict):
# `DISABLE_AFTER_DATASET_CREATE_FOR_CONCURRENT_JOB_TESTS` is used in
# concurrent job testing that do not involve `package_update` and
# `package_revise`.
if not DISABLE_AFTER_DATASET_CREATE_FOR_CONCURRENT_JOB_TESTS:
if not (DISABLE_AFTER_DATASET_CREATE_FOR_CONCURRENT_JOB_TESTS
or IS_BACKGROUND_JOB):
# Check for resources that have been added (e.g. using
# package_revise) during this dataset update.
# We need the "position" of each resource, so we must fetch
Expand Down Expand Up @@ -473,7 +475,7 @@ def after_resource_create(self, context, resource):
rq_kwargs={
"timeout": 500,
"job_id": jid_s3etag,
"depends_on": copy.copy(depends_on),
"enqueue_at_front": True,
})

# Make S3 object public if applicable
Expand Down

0 comments on commit 6e14632

Please sign in to comment.