fix: 브리핑 중복발송 쓰로틀 + 람다 async 스케줄러 버그
- send_briefing에 30분 쓰로틀(_last_briefing_sent) — n8n 중복/재시도로 /briefing/send가 분당 수십 회 호출돼 같은 브리핑이 3~4건+씩 발송되던 폭주를 원천 차단. - 스케줄러 lambda:coro() → 명명 코루틴 함수(_daily_score_notify/_ta_intraday/_ta_close). APScheduler가 lambda 반환 코루틴을 await 안 해 16:30 일간리포트·TA 장마감분석이 'coroutine never awaited'로 실행 안 되던 버그 수정. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -783,9 +783,9 @@ async def startup():
|
||||
redis_cl = aioredis.Redis(
|
||||
host=REDIS_HOST, port=6379, password=REDIS_PASSWORD, db=5, decode_responses=True)
|
||||
await init_db()
|
||||
scheduler.add_job(lambda: job_analyze(limit=500), "cron", day_of_week="mon-fri",
|
||||
scheduler.add_job(_ta_intraday, "cron", day_of_week="mon-fri",
|
||||
hour="9-16", minute="*/30", id="ta_30m", replace_existing=True)
|
||||
scheduler.add_job(lambda: job_analyze(limit=0), "cron", day_of_week="mon-fri",
|
||||
scheduler.add_job(_ta_close, "cron", day_of_week="mon-fri",
|
||||
hour=16, minute=15, id="ta_close", replace_existing=True)
|
||||
scheduler.start()
|
||||
logger.info("ta-engine.started")
|
||||
@@ -870,6 +870,12 @@ async def buy_candidates(limit: int = Query(default=20)):
|
||||
result.append(d)
|
||||
return result
|
||||
|
||||
async def _ta_intraday(): # 코루틴 함수로 등록 (lambda 감싸면 APScheduler가 await 못함)
|
||||
await job_analyze(limit=500)
|
||||
|
||||
async def _ta_close():
|
||||
await job_analyze(limit=0)
|
||||
|
||||
@app.post("/analyze/all")
|
||||
async def analyze_all(limit: int = 0):
|
||||
asyncio.create_task(job_analyze(limit=limit))
|
||||
|
||||
Reference in New Issue
Block a user