Use celery_once to prevent repeat task queueing.

Prevent group updates from being queued multiple times per user.

Default graceful to prevent raising exceptions.
This commit is contained in:
Adarnof
2018-03-19 20:39:27 -04:00
parent 20236cab8a
commit 73e6f576f4
12 changed files with 38 additions and 15 deletions

View File

@@ -3,7 +3,7 @@ import logging
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from celery import shared_task
from allianceauth.services.tasks import QueueOnce
from allianceauth.notifications import notify
from allianceauth.services.hooks import NameFormatter
from .manager import Phpbb3Manager
@@ -35,7 +35,7 @@ class Phpbb3Tasks:
return False
@staticmethod
@shared_task(bind=True, name="phpbb3.update_groups")
@shared_task(bind=True, name="phpbb3.update_groups", base=QueueOnce)
def update_groups(self, pk):
user = User.objects.get(pk=pk)
logger.debug("Updating phpbb3 groups for user %s" % user)