Skip to content

Commit

Permalink
fix: turning off protections so we can retry more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnagro committed Jan 11, 2024
1 parent 4f3f6ea commit 5b4137e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 0 additions & 8 deletions enterprise_catalog/apps/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,6 @@ def update_full_content_metadata_task(self, force=False): # pylint: disable=unu
Args:
force (bool): If true, forces execution of task and ignores time since last run.
"""
if unready_tasks(update_catalog_metadata_task, ONE_HOUR).exists():
raise self.retry(
exc=RequiredTaskUnreadyError(),
)

content_keys = [metadata.content_key for metadata in ContentMetadata.objects.filter(content_type=COURSE)]
_update_full_content_metadata_course(content_keys)
Expand Down Expand Up @@ -568,10 +564,6 @@ def index_enterprise_catalog_in_algolia_task(self, force=False, dry_run=False):
logger.info(
f'{_reindex_algolia_prefix(dry_run)} invoking task with arguments force={force}, dry_run={dry_run}.'
)
if unready_tasks(update_full_content_metadata_task, ONE_HOUR).exists():
raise self.retry(
exc=RequiredTaskUnreadyError(),
)
courses_content_metadata = ContentMetadata.objects.filter(content_type=COURSE)
indexable_course_keys, nonindexable_course_keys = partition_course_keys_for_indexing(
courses_content_metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def add_arguments(self, parser):
default=False,
help='Generate algolia products to index, but do not actually send them to algolia for indexing.',
)
parser.add_argument(
'--no-async',
dest='no_async',
action='store_true',
default=False,
help='Run the task synchronously (without celery).',
)

def handle(self, *args, **options):
"""
Expand All @@ -39,7 +46,10 @@ def handle(self, *args, **options):
try:
force_task_execution = options.get('force', False)
dry_run = options.get('dry_run', False)
if options.get('no_async'):
if options.get('no_async', False):
logger.info(
'index_enterprise_catalog_in_algolia_task launching synchronously.'
)
# For some reason in order to call a celery task in-memory you must pass kwargs as args.
index_enterprise_catalog_in_algolia_task(force_task_execution, dry_run)
else:
Expand Down

0 comments on commit 5b4137e

Please sign in to comment.