fix: v0.14.3 GenerationRecord 加 updated_at + 轮询改固定5秒
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m25s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m25s
- GenerationRecord 加 updated_at 字段(之前只在 QuotaConfig 上,Celery 查 GenerationRecord 报 FieldError) - 后端轮询间隔从渐进式(5s→15s→30s)改为全程固定 5 秒(RPM 12000 足够,400 并发仅用 40%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1b707282ae
commit
7a358ea9ef
@ -48,6 +48,7 @@ class GenerationRecord(models.Model):
|
||||
is_favorited = models.BooleanField(default=False, verbose_name='已收藏')
|
||||
seed = models.BigIntegerField(default=-1, verbose_name='种子值')
|
||||
created_at = models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')
|
||||
updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
|
||||
completed_at = models.DateTimeField(null=True, blank=True, verbose_name='完成时间')
|
||||
|
||||
class Meta:
|
||||
|
||||
@ -7,15 +7,8 @@ from celery import shared_task
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 渐进式轮询间隔
|
||||
# 前 2 分钟:每 5 秒 (24 次)
|
||||
# 2-10 分钟:每 15 秒 (32 次)
|
||||
# 10 分钟后:每 30 秒 (无限)
|
||||
POLL_SCHEDULE = [
|
||||
(120, 5), # 0-120s: every 5s
|
||||
(600, 15), # 120-600s: every 15s
|
||||
(None, 30), # 600s+: every 30s
|
||||
]
|
||||
# 固定轮询间隔:全程每 5 秒(RPM 12000 足够,400 并发仅用 40%)
|
||||
POLL_INTERVAL = 5
|
||||
|
||||
|
||||
@shared_task(bind=True, max_retries=0, ignore_result=True)
|
||||
@ -49,15 +42,8 @@ def poll_video_task(self, record_id):
|
||||
logger.info('poll_video_task: start polling record=%s ark=%s', record_id, ark_task_id)
|
||||
|
||||
while True:
|
||||
# 计算当前间隔
|
||||
interval = POLL_SCHEDULE[-1][1] # default to last
|
||||
for threshold, iv in POLL_SCHEDULE:
|
||||
if threshold is None or elapsed < threshold:
|
||||
interval = iv
|
||||
break
|
||||
|
||||
time.sleep(interval)
|
||||
elapsed += interval
|
||||
time.sleep(POLL_INTERVAL)
|
||||
elapsed += POLL_INTERVAL
|
||||
|
||||
# Re-fetch record to check if frontend already updated it
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user