add batch limit

This commit is contained in:
hjlarry 2025-12-17 10:04:11 +08:00
parent c42e7c8a97
commit 774286797d
2 changed files with 4 additions and 3 deletions

View File

@ -4,10 +4,8 @@ import app
from configs import dify_config
from services.clear_free_plan_expired_workflow_run_logs import WorkflowRunCleanup
CLEANUP_QUEUE = "retention"
@app.celery.task(queue=CLEANUP_QUEUE)
@app.celery.task(queue="retention")
def clean_workflow_runs_task() -> None:
"""
Scheduled cleanup for workflow runs and related records (sandbox tenants only).

View File

@ -39,6 +39,9 @@ class WorkflowRunCleanup:
if self.window_start and self.window_end <= self.window_start:
raise ValueError("end_before must be greater than start_after.")
if batch_size <= 0:
raise ValueError("batch_size must be greater than 0.")
self.batch_size = batch_size
self.billing_cache: dict[str, TenantPlanInfo | None] = {}
self.dry_run = dry_run