Ignore Celery task results
Since we don't use the results of our Celery tasks (all of them return None implicitly), it's prudent to set the ignore_result flag, for a potential performance improvement. See the Celery docs for details [1]. We could do this with the global CELERY_IGNORE_RESULT setting, but it offers more flexibility if we want to use task results in the future to set it on a per-task basis. [1]: https://docs.celeryq.dev/en/stable/userguide/tasks.html#ignore-results-you-don-t-want
This commit is contained in:
parent
00666c4f52
commit
9cbff312a5
12 changed files with 34 additions and 34 deletions
|
@ -506,7 +506,7 @@ def unfurl_related_field(related_field, sort_field=None):
|
|||
return related_field.remote_id
|
||||
|
||||
|
||||
@app.task(queue=BROADCAST)
|
||||
@app.task(queue=BROADCAST, ignore_result=True)
|
||||
def broadcast_task(sender_id: int, activity: str, recipients: List[str]):
|
||||
"""the celery task for broadcast"""
|
||||
user_model = apps.get_model("bookwyrm.User", require_ready=True)
|
||||
|
|
|
@ -65,7 +65,7 @@ class AutoMod(AdminModel):
|
|||
created_by = models.ForeignKey("User", on_delete=models.PROTECT)
|
||||
|
||||
|
||||
@app.task(queue=LOW)
|
||||
@app.task(queue=LOW, ignore_result=True)
|
||||
def automod_task():
|
||||
"""Create reports"""
|
||||
if not AutoMod.objects.exists():
|
||||
|
|
|
@ -327,7 +327,7 @@ class ImportItem(models.Model):
|
|||
)
|
||||
|
||||
|
||||
@app.task(queue=IMPORTS)
|
||||
@app.task(queue=IMPORTS, ignore_result=True)
|
||||
def start_import_task(job_id):
|
||||
"""trigger the child tasks for each row"""
|
||||
job = ImportJob.objects.get(id=job_id)
|
||||
|
@ -346,7 +346,7 @@ def start_import_task(job_id):
|
|||
job.save()
|
||||
|
||||
|
||||
@app.task(queue=IMPORTS)
|
||||
@app.task(queue=IMPORTS, ignore_result=True)
|
||||
def import_item_task(item_id):
|
||||
"""resolve a row into a book"""
|
||||
item = ImportItem.objects.get(id=item_id)
|
||||
|
|
|
@ -469,7 +469,7 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
|
|||
return super().save(*args, **kwargs)
|
||||
|
||||
|
||||
@app.task(queue=LOW)
|
||||
@app.task(queue=LOW, ignore_result=True)
|
||||
def set_remote_server(user_id):
|
||||
"""figure out the user's remote server in the background"""
|
||||
user = User.objects.get(id=user_id)
|
||||
|
@ -513,7 +513,7 @@ def get_or_create_remote_server(domain, refresh=False):
|
|||
return server
|
||||
|
||||
|
||||
@app.task(queue=LOW)
|
||||
@app.task(queue=LOW, ignore_result=True)
|
||||
def get_remote_reviews(outbox):
|
||||
"""ingest reviews by a new remote bookwyrm user"""
|
||||
outbox_page = outbox + "?page=true&type=Review"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue