From 427d0c4fc89aac8c4c18cd97317bb897fd903710 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 16 Dec 2022 14:20:50 -0800 Subject: [PATCH] Create a separate celery queue for imports --- bookwyrm/models/import_job.py | 6 +++--- bookwyrm/tasks.py | 2 ++ docker-compose.yml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index d8cfad314..b009048d9 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -19,7 +19,7 @@ from bookwyrm.models import ( Review, ReviewRating, ) -from bookwyrm.tasks import app, LOW +from bookwyrm.tasks import app, LOW, IMPORTS from .fields import PrivacyLevels @@ -328,7 +328,7 @@ class ImportItem(models.Model): ) -@app.task(queue=LOW) +@app.task(queue=IMPORTS) def start_import_task(job_id): """trigger the child tasks for each row""" job = ImportJob.objects.get(id=job_id) @@ -345,7 +345,7 @@ def start_import_task(job_id): job.save() -@app.task(queue=LOW) +@app.task(queue=IMPORTS) def import_item_task(item_id): """resolve a row into a book""" item = ImportItem.objects.get(id=item_id) diff --git a/bookwyrm/tasks.py b/bookwyrm/tasks.py index 09e1d267e..ec018e179 100644 --- a/bookwyrm/tasks.py +++ b/bookwyrm/tasks.py @@ -14,3 +14,5 @@ app = Celery( LOW = "low_priority" MEDIUM = "medium_priority" HIGH = "high_priority" +# import items get their own queue because they're such a pain in the ass +IMPORTS = "imports" diff --git a/docker-compose.yml b/docker-compose.yml index 59d4137d2..e98128544 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,7 +62,7 @@ services: build: . networks: - main - command: celery -A celerywyrm worker -l info -Q high_priority,medium_priority,low_priority + command: celery -A celerywyrm worker -l info -Q high_priority,medium_priority,low_priority,imports volumes: - .:/app - static_volume:/app/static