Skip to content

Commit 28ef12e

Browse files
fix: allow our event handling tasks to call subtasks
1 parent be26b61 commit 28ef12e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • openedx/core/djangoapps/content_libraries

openedx/core/djangoapps/content_libraries/tasks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def send_change_events_for_modified_entities(
166166
container_key_str=str(container_key),
167167
old_version_id=change.old_version_id,
168168
new_version_id=change.new_version_id,
169-
)
169+
).forget() # Best practice: free celery result using forget() after calling delay()
170170
else:
171171
log.error("Unknown publishable entity type: %s", entity)
172172
continue
@@ -726,7 +726,11 @@ def dispatch_and_wait(task_fn: Task, wait_for_full_completion: bool = False, **k
726726
result: AsyncResult = task_fn.delay(**kwargs)
727727
# Try waiting a bit for the task to finish before we complete the request:
728728
try:
729-
result.get(timeout=10)
729+
# We use `disable_sync_subtasks=False` because some of our tasks emit
730+
# events whose handlers then spawn additional tasks which are sometimes
731+
# synchronous. Ideal usage of celery would be to "chain" the tasks
732+
# instead of spawning subtasks, but that would require a major refactor.
733+
result.get(timeout=10, disable_sync_subtasks=False)
730734
except CeleryTimeout:
731735
pass
732736
# This is fine! The search index is still being updated, and/or other

0 commit comments

Comments
 (0)