fix(realestate-lab): 최종 리뷰 이슈 수정 — FK CASCADE, 단일 연결, 동시성 가드

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 08:49:05 +09:00
parent bdfcdee5fd
commit afc159c84d
3 changed files with 41 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
import os
import logging
import threading
from contextlib import asynccontextmanager
from fastapi import BackgroundTasks, FastAPI, Query, HTTPException
from fastapi.middleware.cors import CORSMiddleware
@@ -110,9 +111,18 @@ def api_announcement_delete(ann_id: int):
# ── 수집 API ─────────────────────────────────────────────────────────────────
_collect_lock = threading.Lock()
def _run_collect_and_match():
collect_all()
run_matching()
if not _collect_lock.acquire(blocking=False):
logger.info("수집 이미 진행 중 — 건너뜀")
return
try:
collect_all()
run_matching()
finally:
_collect_lock.release()
@app.post("/api/realestate/collect")