Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add Celery beat expiration option in update product search entry (#11807)
Mika458099344fd9
diff --git a/saleor/product/tasks.py b/saleor/product/tasks.pyindex 0ebe6625f8..06d50fb274 100644--- a/saleor/product/tasks.py+++ b/saleor/product/tasks.py@@ -122,7 +122,10 @@ def _get_preorder_variants_to_clean():)[email protected](queue=settings.UPDATE_SEARCH_VECTOR_INDEX_QUEUE_NAME, expires=20)+ queue=settings.UPDATE_SEARCH_VECTOR_INDEX_QUEUE_NAME,+ expires=settings.BEAT_UPDATE_SEARCH_EXPIRE_AFTER_SEC,+)def update_products_search_vector_task():products = Product.objects.filter(search_index_dirty=True).order_by()[:PRODUCTS_BATCH_SIZEdiff --git a/saleor/settings.py b/saleor/settings.pyindex 6bfefed3b4..0438e77769 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -546,6 +546,16 @@ CELERY_TASK_ROUTES = {},}+# Defines after how many seconds should the task triggered by the Celery beat+# entry 'update-products-search-vectors' expire if it wasn't picked up by a worker.+BEAT_UPDATE_SEARCH_EXPIRE_AFTER_SEC = 20++# Defines the Celery beat scheduler entries.+#+# Note: if a Celery task triggered by a Celery beat entry has an expiration+# @task(expires=...), the Celery beat scheduler entry should also define+# the expiration value. This makes sure if the task or scheduling is wrapped+# by custom code (e.g., a Saleor fork), the expiration is still present.CELERY_BEAT_SCHEDULE = {"delete-empty-allocations": {"task": "saleor.warehouse.tasks.delete_empty_allocations_task",@@ -586,6 +596,7 @@ CELERY_BEAT_SCHEDULE = {"update-products-search-vectors": {"task": "saleor.product.tasks.update_products_search_vector_task","schedule": timedelta(seconds=20),+ "options": {"expires": BEAT_UPDATE_SEARCH_EXPIRE_AFTER_SEC},},}