From 0e048f82ef0f678532ef1e320ea7ffd102588ffc Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Sun, 29 Mar 2026 17:35:28 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20universe=20build=20event=20loop=20?= =?UTF-8?q?=EC=B0=A8=EB=8B=A8=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _PRICE_BATCH 100 → 50 (배치당 부하 감소) - 배치 완료 후 asyncio.sleep(1) 추가 (event loop yield) Co-Authored-By: Claude Sonnet 4.6 --- app/services/universe_service.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/universe_service.py b/app/services/universe_service.py index b3aa948..fb45c63 100644 --- a/app/services/universe_service.py +++ b/app/services/universe_service.py @@ -30,7 +30,7 @@ from app.services.sec_http_client import SECHttpClient logger = logging.getLogger(__name__) _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 _SCREEN_PAGE = 250 # max per yf.screen() call @@ -399,6 +399,8 @@ class UniverseService: f"Universe: batch {batch_num}/{total_batches} — " 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( f"Universe: build complete — {len(ticker_list)} tickers, "