mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Tweak the Celery tasks retry
This commit is contained in:
parent
ff55b9e9dc
commit
4a882fb7ba
1 changed files with 6 additions and 0 deletions
6
tasks.py
6
tasks.py
|
@ -6,6 +6,8 @@ import random
|
|||
import requests
|
||||
from celery import Celery
|
||||
from little_boxes import activitypub as ap
|
||||
from little_boxes.errors import ActivityGoneError
|
||||
from little_boxes.errors import ActivityNotFoundError
|
||||
from little_boxes.httpsig import HTTPSigAuth
|
||||
from little_boxes.linked_data_sig import generate_signature
|
||||
from requests.exceptions import HTTPError
|
||||
|
@ -49,6 +51,8 @@ def process_new_activity(self, iri: str) -> None:
|
|||
)
|
||||
|
||||
log.info(f"new activity {iri} processed")
|
||||
except (ActivityGoneError, ActivityNotFoundError):
|
||||
log.exception("failed to process activity {iri}")
|
||||
except Exception as err:
|
||||
log.exception(f"failed to process new activity {iri}")
|
||||
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
||||
|
@ -79,6 +83,8 @@ def cache_attachments(self, iri: str) -> None:
|
|||
|
||||
log.info(f"attachments cached for {iri}")
|
||||
|
||||
except (ActivityGoneError, ActivityNotFoundError):
|
||||
log.exception("failed to process activity {iri}")
|
||||
except Exception as err:
|
||||
log.exception(f"failed to process new activity {iri}")
|
||||
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
||||
|
|
Loading…
Reference in a new issue