stdout/stderr UTF-8 강제 + print 메시지에서 비-ASCII 기호 제거

## 배경
이전 자정에 일일 리포트가 발송되지 않은 1차 원인은 긴 sleep 의존(별도 커밋
057335a 에서 폴링 방식으로 전환). 그러나 폴링 적용 후 다시 살펴보니, 새
print 문에서 cp949 (Windows 콘솔 기본 인코딩) 환경에서 em-dash(—)와
right arrow(→) 인코딩 실패로 print 가 예외를 던져 try/except 가
"[일일리포트 스레드 오류]" 로 매번 잡히고 있었음. 자정 발송 로직 자체는
실행되어도 로그가 silent fail 가능성. 향후 동일 문제 차단을 위해 처리.

## 변경
- sys.stdout.reconfigure(encoding="utf-8") + sys.stderr 동일 처리.
- PYTHONIOENCODING=utf-8 환경변수도 설정 (subprocess 가 상속받도록).
- 로그 메시지의 em-dash -> "--", right arrow -> "->" 로 ASCII 화 (이중
  안전장치).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
ILSEON-RYU
2026-05-02 00:08:53 +09:00
parent 057335a173
commit 577fb44914
+5 -3
View File
@@ -1,7 +1,9 @@
import sys
import os
sys.stdout.reconfigure(line_buffering=True)
sys.stdout.reconfigure(line_buffering=True, encoding="utf-8")
sys.stderr.reconfigure(line_buffering=True, encoding="utf-8")
os.environ["PYTHONUNBUFFERED"] = "1"
os.environ["PYTHONIOENCODING"] = "utf-8"
import time
import requests
@@ -746,9 +748,9 @@ def _daily_report_loop():
today_str = now_kst.strftime("%Y-%m-%d")
if _last_report_date is None:
_last_report_date = today_str
print(f"[일일리포트] 스레드 기동 다음 자정({today_str} 24:00 KST) 까지 대기")
print(f"[일일리포트] 스레드 기동 -- 다음 자정({today_str} 24:00 KST) 까지 대기")
elif _last_report_date != today_str:
print(f"[일일리포트] 자정 통과 감지 발송 ({today_str})")
print(f"[일일리포트] 자정 통과 감지 -> 발송 ({today_str})")
with _alert_lock:
symbol = _alert_symbol
send_daily_report(symbol)