2021-03-01 21:15:17 +01:00
|
|
|
# import
|
|
|
|
import requests
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
import celery
|
|
|
|
import sqlalchemy
|
|
|
|
|
2021-03-07 14:51:59 +01:00
|
|
|
# local imports
|
2021-03-07 19:01:44 +01:00
|
|
|
from cic_eth.error import (
|
|
|
|
SignerError,
|
|
|
|
EthError,
|
|
|
|
)
|
2021-03-07 14:51:59 +01:00
|
|
|
|
2021-03-01 21:15:17 +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,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class CriticalWeb3Task(CriticalTask):
|
|
|
|
autoretry_for = (
|
|
|
|
requests.exceptions.ConnectionError,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class CriticalSQLAlchemyAndWeb3Task(CriticalTask):
|
|
|
|
autoretry_for = (
|
|
|
|
sqlalchemy.exc.DatabaseError,
|
|
|
|
sqlalchemy.exc.TimeoutError,
|
|
|
|
requests.exceptions.ConnectionError,
|
2021-03-07 19:01:44 +01:00
|
|
|
EthError,
|
2021-03-01 21:15:17 +01:00
|
|
|
)
|
2021-03-07 14:51:59 +01:00
|
|
|
|
|
|
|
class CriticalSQLAlchemyAndSignerTask(CriticalTask):
|
|
|
|
autoretry_for = (
|
|
|
|
sqlalchemy.exc.DatabaseError,
|
|
|
|
sqlalchemy.exc.TimeoutError,
|
|
|
|
SignerError,
|
|
|
|
)
|
|
|
|
|
|
|
|
class CriticalWeb3AndSignerTask(CriticalTask):
|
|
|
|
autoretry_for = (
|
|
|
|
requests.exceptions.ConnectionError,
|
|
|
|
SignerError,
|
|
|
|
)
|