Shoraky commited on
Commit
6f6bf2c
·
1 Parent(s): e7269f1

Raise active analysis queue limit to five

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -45,6 +45,7 @@ YOLO_MODEL_HUB_FILE = "yolo11x.pt"
45
  YOLO_MODEL_REPO_TYPE = "model"
46
  YOLO_IMGSZ = 896
47
  MAX_VIDEO_SIZE_BYTES = int(os.environ.get("MAX_VIDEO_SIZE_MB", "2048")) * 1024 * 1024
 
48
  MAX_ACTIONS_SIZE_BYTES = 32 * 1024 * 1024
49
  MAX_CALIBRATION_SIZE_BYTES = 256 * 1024 * 1024
50
 
@@ -592,8 +593,8 @@ async def analyze(request: Request, playerId: str = Form(...), clientId: UUID =
592
  active_jobs = [job for job in jobs.values() if job["status"] in {"uploading", "queued", "running"}]
593
  if any(job["userId"] == user_id for job in active_jobs):
594
  raise HTTPException(429, "Finish or cancel your active analysis before starting another")
595
- if len(active_jobs) >= 3:
596
- raise HTTPException(429, "The analysis queue is full. Try again shortly")
597
  cutoff = int(time.time() * 1000) - 24 * 60 * 60 * 1000
598
  for key, job in list(jobs.items()):
599
  if job["status"] in {"completed", "failed", "cancelled", "sync_failed"} and job["updatedAt"] < cutoff:
 
45
  YOLO_MODEL_REPO_TYPE = "model"
46
  YOLO_IMGSZ = 896
47
  MAX_VIDEO_SIZE_BYTES = int(os.environ.get("MAX_VIDEO_SIZE_MB", "2048")) * 1024 * 1024
48
+ MAX_ACTIVE_ANALYSES = 5
49
  MAX_ACTIONS_SIZE_BYTES = 32 * 1024 * 1024
50
  MAX_CALIBRATION_SIZE_BYTES = 256 * 1024 * 1024
51
 
 
593
  active_jobs = [job for job in jobs.values() if job["status"] in {"uploading", "queued", "running"}]
594
  if any(job["userId"] == user_id for job in active_jobs):
595
  raise HTTPException(429, "Finish or cancel your active analysis before starting another")
596
+ if len(active_jobs) >= MAX_ACTIVE_ANALYSES:
597
+ raise HTTPException(429, f"The analysis queue is full (maximum {MAX_ACTIVE_ANALYSES} active jobs). Try again when a slot opens.")
598
  cutoff = int(time.time() * 1000) - 24 * 60 * 60 * 1000
599
  for key, job in list(jobs.items()):
600
  if job["status"] in {"completed", "failed", "cancelled", "sync_failed"} and job["updatedAt"] < cutoff: