mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-08 16:16:18 +01:00
Stop using task_self in bound tasks.
This commit is contained in:
@@ -60,7 +60,7 @@ class DiscordTasks:
|
||||
|
||||
@staticmethod
|
||||
@shared_task(bind=True, name='discord.update_groups', base=QueueOnce)
|
||||
def update_groups(task_self, pk):
|
||||
def update_groups(self, pk):
|
||||
user = User.objects.get(pk=pk)
|
||||
logger.debug("Updating discord groups for user %s" % user)
|
||||
if DiscordTasks.has_account(user):
|
||||
@@ -71,7 +71,7 @@ class DiscordTasks:
|
||||
except DiscordApiBackoff as bo:
|
||||
logger.info("Discord group sync API back off for %s, "
|
||||
"retrying in %s seconds" % (user, bo.retry_after_seconds))
|
||||
raise task_self.retry(countdown=bo.retry_after_seconds)
|
||||
raise self.retry(countdown=bo.retry_after_seconds)
|
||||
except HTTPError as e:
|
||||
if e.response.status_code == 404:
|
||||
try:
|
||||
@@ -82,9 +82,9 @@ class DiscordTasks:
|
||||
finally:
|
||||
raise e
|
||||
except Exception as e:
|
||||
if task_self:
|
||||
if self:
|
||||
logger.exception("Discord group sync failed for %s, retrying in 10 mins" % user)
|
||||
raise task_self.retry(countdown=60 * 10)
|
||||
raise self.retry(countdown=60 * 10)
|
||||
else:
|
||||
# Rethrow
|
||||
raise e
|
||||
@@ -101,7 +101,7 @@ class DiscordTasks:
|
||||
|
||||
@staticmethod
|
||||
@shared_task(bind=True, name='discord.update_nickname', base=QueueOnce)
|
||||
def update_nickname(task_self, pk):
|
||||
def update_nickname(self, pk):
|
||||
user = User.objects.get(pk=pk)
|
||||
logger.debug("Updating discord nickname for user %s" % user)
|
||||
if DiscordTasks.has_account(user):
|
||||
@@ -113,11 +113,11 @@ class DiscordTasks:
|
||||
except DiscordApiBackoff as bo:
|
||||
logger.info("Discord nickname update API back off for %s, "
|
||||
"retrying in %s seconds" % (user, bo.retry_after_seconds))
|
||||
raise task_self.retry(countdown=bo.retry_after_seconds)
|
||||
raise self.retry(countdown=bo.retry_after_seconds)
|
||||
except Exception as e:
|
||||
if task_self:
|
||||
if self:
|
||||
logger.exception("Discord nickname sync failed for %s, retrying in 10 mins" % user)
|
||||
raise task_self.retry(countdown=60 * 10)
|
||||
raise self.retry(countdown=60 * 10)
|
||||
else:
|
||||
# Rethrow
|
||||
raise e
|
||||
|
||||
Reference in New Issue
Block a user