summaryrefslogtreecommitdiff
path: root/postgresqleu/confreg/models.py
diff options
context:
space:
mode:
authorMagnus Hagander2023-10-16 20:49:50 +0000
committerMagnus Hagander2023-10-16 20:58:59 +0000
commit45b8e2e931ac00c00d9525e346eb458c3a2e8aa3 (patch)
tree64934858a81d5027956ae520ef22ff5f27e71b48 /postgresqleu/confreg/models.py
parente97fe48b16da3935a073188f1135cca68ad7a5ee (diff)
Re-think error handling in social media posting
As 4ab83bb5 noted, on permanent error (such as when twitter has blocked your account...), we got stuck in an endless loop in the daemon. Even worse, after a second retry the cronjob would get killed on the 120 second timeout, and the cycle start over... Instead, implement an error counter and an exponentially longer backoff for retries until 10 retries have been made after wihch we give up.
Diffstat (limited to 'postgresqleu/confreg/models.py')
-rw-r--r--postgresqleu/confreg/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/postgresqleu/confreg/models.py b/postgresqleu/confreg/models.py
index 7a472c33..8ed11cd8 100644
--- a/postgresqleu/confreg/models.py
+++ b/postgresqleu/confreg/models.py
@@ -1557,6 +1557,7 @@ class ConferenceTweetQueue(models.Model):
postids = models.JSONField(null=False, blank=False, default=dict)
replytotweetid = models.BigIntegerField(null=True, blank=True, verbose_name="Reply to tweet")
remainingtosend = models.ManyToManyField(MessagingProvider, blank=True)
+ errorcount = models.IntegerField(null=False, blank=False, default=0)
comment = models.CharField(max_length=200, null=False, blank=True, verbose_name="Internal comment")
metadata = models.JSONField(null=False, blank=False, default=dict)
@@ -1596,6 +1597,15 @@ class ConferenceTweetQueue(models.Model):
return self.contents
+class ConferenceTweetQueueErrorLog(models.Model):
+ tweet = models.ForeignKey(ConferenceTweetQueue, null=False, on_delete=models.CASCADE)
+ ts = models.DateTimeField(blank=False, null=False, auto_now_add=True)
+ message = models.CharField(max_length=250, null=False, blank=False)
+
+ class Meta:
+ ordering = ('ts', )
+
+
class ConferenceIncomingTweet(models.Model):
conference = models.ForeignKey(Conference, null=False, on_delete=models.CASCADE)
provider = models.ForeignKey(MessagingProvider, null=True, on_delete=models.SET_NULL)