Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop ignoring task results #2805

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bookwyrm/activitypub/base_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def serialize(self, **kwargs):
return data


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
@transaction.atomic
def set_related_field(
model_name, origin_model_name, related_field_name, related_remote_id, data
Expand Down
16 changes: 8 additions & 8 deletions bookwyrm/activitystreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,31 +497,31 @@ def remove_statuses_on_unshelve(sender, instance, *args, **kwargs):
# ---- TASKS


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def add_book_statuses_task(user_id, book_id):
"""add statuses related to a book on shelve"""
user = models.User.objects.get(id=user_id)
book = models.Edition.objects.get(id=book_id)
BooksStream().add_book_statuses(user, book)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def remove_book_statuses_task(user_id, book_id):
"""remove statuses about a book from a user's books feed"""
user = models.User.objects.get(id=user_id)
book = models.Edition.objects.get(id=book_id)
BooksStream().remove_book_statuses(user, book)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def populate_stream_task(stream, user_id):
"""background task for populating an empty activitystream"""
user = models.User.objects.get(id=user_id)
stream = streams[stream]
stream.populate_streams(user)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def remove_status_task(status_ids):
"""remove a status from any stream it might be in"""
# this can take an id or a list of ids
Expand All @@ -536,7 +536,7 @@ def remove_status_task(status_ids):
)


@app.task(queue=HIGH, ignore_result=True)
@app.task(queue=HIGH)
def add_status_task(status_id, increment_unread=False):
"""add a status to any stream it should be in"""
status = models.Status.objects.select_subclasses().get(id=status_id)
Expand All @@ -548,7 +548,7 @@ def add_status_task(status_id, increment_unread=False):
stream.add_status(status, increment_unread=increment_unread)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def remove_user_statuses_task(viewer_id, user_id, stream_list=None):
"""remove all statuses by a user from a viewer's stream"""
stream_list = [streams[s] for s in stream_list] if stream_list else streams.values()
Expand All @@ -558,7 +558,7 @@ def remove_user_statuses_task(viewer_id, user_id, stream_list=None):
stream.remove_user_statuses(viewer, user)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def add_user_statuses_task(viewer_id, user_id, stream_list=None):
"""add all statuses by a user to a viewer's stream"""
stream_list = [streams[s] for s in stream_list] if stream_list else streams.values()
Expand All @@ -568,7 +568,7 @@ def add_user_statuses_task(viewer_id, user_id, stream_list=None):
stream.add_user_statuses(viewer, user)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def handle_boost_task(boost_id):
"""remove the original post and other, earlier boosts"""
instance = models.Status.objects.get(id=boost_id)
Expand Down
4 changes: 2 additions & 2 deletions bookwyrm/connectors/connector_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_or_create_connector(remote_id):
return load_connector(connector_info)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def load_more_data(connector_id, book_id):
"""background the work of getting all 10,000 editions of LoTR"""
connector_info = models.Connector.objects.get(id=connector_id)
Expand All @@ -152,7 +152,7 @@ def load_more_data(connector_id, book_id):
connector.expand_book_data(book)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def create_edition_task(connector_id, work_id, data):
"""separate task for each of the 10,000 editions of LoTR"""
connector_info = models.Connector.objects.get(id=connector_id)
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/emailing.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def format_email(email_name, data):
return (subject, html_content, text_content)


@app.task(queue=HIGH, ignore_result=True)
@app.task(queue=HIGH)
def send_email(recipient, subject, html_content, text_content):
"""use a task to send the email"""
email = EmailMultiAlternatives(
Expand Down
10 changes: 5 additions & 5 deletions bookwyrm/lists_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ def add_list_on_account_create_command(user_id):


# ---- TASKS
@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def populate_lists_task(user_id):
"""background task for populating an empty list stream"""
user = models.User.objects.get(id=user_id)
ListsStream().populate_lists(user)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def remove_list_task(list_id, re_add=False):
"""remove a list from any stream it might be in"""
stores = models.User.objects.filter(local=True, is_active=True).values_list(
Expand All @@ -239,22 +239,22 @@ def remove_list_task(list_id, re_add=False):
add_list_task.delay(list_id)


@app.task(queue=HIGH, ignore_result=True)
@app.task(queue=HIGH)
def add_list_task(list_id):
"""add a list to any stream it should be in"""
book_list = models.List.objects.get(id=list_id)
ListsStream().add_list(book_list)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def remove_user_lists_task(viewer_id, user_id, exclude_privacy=None):
"""remove all lists by a user from a viewer's stream"""
viewer = models.User.objects.get(id=viewer_id)
user = models.User.objects.get(id=user_id)
ListsStream().remove_user_lists(viewer, user, exclude_privacy=exclude_privacy)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def add_user_lists_task(viewer_id, user_id):
"""add all lists by a user to a viewer's stream"""
viewer = models.User.objects.get(id=viewer_id)
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/models/activitypub_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def unfurl_related_field(related_field, sort_field=None):
return related_field.remote_id


@app.task(queue=BROADCAST, ignore_result=True)
@app.task(queue=BROADCAST)
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)
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/models/antispam.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AutoMod(AdminModel):
created_by = models.ForeignKey("User", on_delete=models.PROTECT)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def automod_task():
"""Create reports"""
if not AutoMod.objects.exists():
Expand Down
4 changes: 2 additions & 2 deletions bookwyrm/models/import_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def __str__(self):
)


@app.task(queue=IMPORTS, ignore_result=True)
@app.task(queue=IMPORTS)
def start_import_task(job_id):
"""trigger the child tasks for each row"""
job = ImportJob.objects.get(id=job_id)
Expand All @@ -346,7 +346,7 @@ def start_import_task(job_id):
job.save()


@app.task(queue=IMPORTS, ignore_result=True)
@app.task(queue=IMPORTS)
def import_item_task(item_id):
"""resolve a row into a book"""
item = ImportItem.objects.get(id=item_id)
Expand Down
4 changes: 2 additions & 2 deletions bookwyrm/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def save(self, *args, **kwargs):
return super().save(*args, **kwargs)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def set_remote_server(user_id):
"""figure out the user's remote server in the background"""
user = User.objects.get(id=user_id)
Expand Down Expand Up @@ -513,7 +513,7 @@ def get_or_create_remote_server(domain, refresh=False):
return server


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def get_remote_reviews(outbox):
"""ingest reviews by a new remote bookwyrm user"""
outbox_page = outbox + "?page=true&type=Review"
Expand Down
8 changes: 4 additions & 4 deletions bookwyrm/preview_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def save_and_cleanup(image, instance=None):


# pylint: disable=invalid-name
@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def generate_site_preview_image_task():
"""generate preview_image for the website"""
if not settings.ENABLE_PREVIEW_IMAGES:
Expand All @@ -445,7 +445,7 @@ def generate_site_preview_image_task():


# pylint: disable=invalid-name
@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def generate_edition_preview_image_task(book_id):
"""generate preview_image for a book"""
if not settings.ENABLE_PREVIEW_IMAGES:
Expand All @@ -470,7 +470,7 @@ def generate_edition_preview_image_task(book_id):
save_and_cleanup(image, instance=book)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def generate_user_preview_image_task(user_id):
"""generate preview_image for a user"""
if not settings.ENABLE_PREVIEW_IMAGES:
Expand All @@ -496,7 +496,7 @@ def generate_user_preview_image_task(user_id):
save_and_cleanup(image, instance=user)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def remove_user_preview_image_task(user_id):
"""remove preview_image for a user"""
if not settings.ENABLE_PREVIEW_IMAGES:
Expand Down
12 changes: 6 additions & 6 deletions bookwyrm/suggested_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,20 @@ def domain_level_update(sender, instance, created, update_fields=None, **kwargs)
# ------------------- TASKS


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def rerank_suggestions_task(user_id):
"""do the hard work in celery"""
suggested_users.rerank_user_suggestions(user_id)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def rerank_user_task(user_id, update_only=False):
"""do the hard work in celery"""
user = models.User.objects.get(id=user_id)
suggested_users.rerank_obj(user, update_only=update_only)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def remove_user_task(user_id):
"""do the hard work in celery"""
user = models.User.objects.get(id=user_id)
Expand All @@ -266,14 +266,14 @@ def remove_user_task(user_id):
)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def remove_suggestion_task(user_id, suggested_user_id):
"""remove a specific user from a specific user's suggestions"""
suggested_user = models.User.objects.get(id=suggested_user_id)
suggested_users.remove_suggestion(user_id, suggested_user)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def bulk_remove_instance_task(instance_id):
"""remove a bunch of users from recs"""
for user in models.User.objects.filter(federated_server__id=instance_id):
Expand All @@ -282,7 +282,7 @@ def bulk_remove_instance_task(instance_id):
)


@app.task(queue=LOW, ignore_result=True)
@app.task(queue=LOW)
def bulk_add_instance_task(instance_id):
"""remove a bunch of users from recs"""
for user in models.User.objects.filter(federated_server__id=instance_id):
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/views/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def sometimes_async_activity_task(activity_json, queue=MEDIUM):
activity_task.apply_async(args=(activity_json,), queue=queue)


@app.task(queue=MEDIUM, ignore_result=True)
@app.task(queue=MEDIUM)
def activity_task(activity_json):
"""do something with this json we think is legit"""
# lets see if the activitypub module can make sense of this json
Expand Down