| 123456789101112131415161718192021222324252627 | import loggingfrom celery import shared_task  # type: ignorefrom extensions.ext_database import dbfrom models.account import Accountfrom services.billing_service import BillingServicefrom tasks.mail_account_deletion_task import send_deletion_success_tasklogger = logging.getLogger(__name__)@shared_task(queue="dataset")def delete_account_task(account_id):    account = db.session.query(Account).filter(Account.id == account_id).first()    try:        BillingService.delete_account(account_id)    except Exception as e:        logger.exception(f"Failed to delete account {account_id} from billing service.")        raise    if not account:        logger.error(f"Account {account_id} not found.")        return    # send success email    send_deletion_success_task.delay(account.email)
 |