Ich leite Sellerie mit Django und Sellerie -Beat.from celery import shared_task
from django.db import transaction
@shared_task(queue="outer_queue")
def sync_all_items():
"""
This outer task is triggered by Celery Beat every 30 minutes.
It scans the DB for outdated items and enqueues a per-item task.
"""
items = Item.objects.find_outdated_items()
for item in items:
# I expect this to enqueue on outer_queue as well
process_item.apply_async_on_commit(args=(item.pk,))
@shared_task(queue="outer_queue")
def process_item(item_id):
do_some_processing(item_id=item_id)
< /code>
Sellerie -Beat -Konfiguration: < /p>
CELERY_BEAT_SCHEDULE = {
"sync_all_items": {
"task": "myapp.tasks.sync_all_items",
"schedule": crontab(minute="*/30"),
# Beat is explicitly sending the outer task to outer_queue
"options": {"queue": "outer_queue"},
}
}
< /code>
Ich habe es versucht: < /p>
Hinzufügen von Queue = 'oUter_queue' to apply_async_on_commit < /p>
< /li>
Aufruf von Process_item.delay (Element (Element). /> Verwendung .Apply_async (args = [item.pk], queue = 'oUter_queue') in transaction.on_commit < /p>
< /li>
< /ul>
Die Sellerie -Aufgabe, die in einer anderen Aufgabe aufgerufen wurde ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post