2021-03-04 17:47:13 +01:00
|
|
|
# standard imports
|
|
|
|
|
|
|
|
# third-party imports
|
|
|
|
import celery
|
|
|
|
import sqlalchemy
|
|
|
|
|
|
|
|
# local imports
|
2021-04-07 08:21:15 +02:00
|
|
|
from cic_ussd.error import MetadataStoreError
|
2021-03-04 17:47:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CriticalTask(celery.Task):
|
|
|
|
retry_jitter = True
|
|
|
|
retry_backoff = True
|
|
|
|
retry_backoff_max = 8
|
|
|
|
|
|
|
|
|
|
|
|
class CriticalSQLAlchemyTask(CriticalTask):
|
|
|
|
autoretry_for = (
|
|
|
|
sqlalchemy.exc.DatabaseError,
|
|
|
|
sqlalchemy.exc.TimeoutError,
|
|
|
|
)
|
2021-04-07 08:21:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
class CriticalMetadataTask(CriticalTask):
|
|
|
|
autoretry_for = (
|
|
|
|
MetadataStoreError,
|
|
|
|
)
|