use dynamic delay retry

This commit is contained in:
bakatrouble 2023-12-16 17:54:02 +03:00
parent 7961e016eb
commit 49a1b62f21

View File

@ -3,6 +3,8 @@ import logging
import os
import traceback
from telegram.error import RetryAfter
from config.celery import app
from djconfig import config
@ -32,6 +34,8 @@ def upload_image_rpc(self, queued_image_pk, fpath, caption):
qi.processed = True
qi.save()
os.unlink(fpath)
except RetryAfter as e:
raise self.retry(exc=e, countdown=int(e.retry_after))
except Exception as e:
traceback.print_exc()
raise self.retry(exc=e, countdown=5)