您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

delete_account_task.py 789B

1234567891011121314151617181920212223242526
  1. import logging
  2. from celery import shared_task
  3. from extensions.ext_database import db
  4. from models.account import Account
  5. from services.billing_service import BillingService
  6. from tasks.mail_account_deletion_task import send_deletion_success_task
  7. logger = logging.getLogger(__name__)
  8. @shared_task(queue="dataset")
  9. def delete_account_task(account_id):
  10. account = db.session.query(Account).where(Account.id == account_id).first()
  11. try:
  12. BillingService.delete_account(account_id)
  13. except Exception:
  14. logger.exception("Failed to delete account %s from billing service.", account_id)
  15. raise
  16. if not account:
  17. logger.error("Account %s not found.", account_id)
  18. return
  19. # send success email
  20. send_deletion_success_task.delay(account.email)