fix: universe build event loop 차단 방지

- _PRICE_BATCH 100 → 50 (배치당 부하 감소)
- 배치 완료 후 asyncio.sleep(1) 추가 (event loop yield)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
I Luk Kim 5 months ago
parent b54ac6d5b7
commit 0e048f82ef

@ -30,7 +30,7 @@ from app.services.sec_http_client import SECHttpClient
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
_CHUNK = 3000 # asyncpg 32767-param limit (10 cols × 3000 = 30000) _CHUNK = 3000 # asyncpg 32767-param limit (10 cols × 3000 = 30000)
_PRICE_BATCH = 100 # tickers per yfinance bulk download _PRICE_BATCH = 50 # tickers per yfinance bulk download (smaller = more responsive)
_SEC_CONCURRENCY = 3 # concurrent SEC EDGAR companyfacts requests _SEC_CONCURRENCY = 3 # concurrent SEC EDGAR companyfacts requests
_SCREEN_PAGE = 250 # max per yf.screen() call _SCREEN_PAGE = 250 # max per yf.screen() call
@ -399,6 +399,8 @@ class UniverseService:
f"Universe: batch {batch_num}/{total_batches}" f"Universe: batch {batch_num}/{total_batches}"
f"{len(batch)} tickers, {len(batch_rows)} snapshot rows" f"{len(batch)} tickers, {len(batch_rows)} snapshot rows"
) )
# Yield to event loop between batches to keep API responsive
await asyncio.sleep(1)
logger.info( logger.info(
f"Universe: build complete — {len(ticker_list)} tickers, " f"Universe: build complete — {len(ticker_list)} tickers, "

Loading…
Cancel
Save