fix: force UTF-8 on stdio so the server starts on a Windows console
Every log line in app.py is emoji-prefixed and a Windows console is cp1252
by default, so _recover_jobs_from_disk() kills the server during startup:
print(f"♻️ Recovered {recovered} completed job(s) from disk.")
UnicodeEncodeError: 'charmap' codec can't encode characters in 0-1
ERROR: Application startup failed. Exiting.
It never binds a port, so the dashboard is simply unreachable on a stock
Windows box. PYTHONIOENCODING=utf-8 works around it, but that has to be
known before the first run, and the traceback does not suggest it.
subtitles._configure_stdio already does exactly this for the transcription
path. The server needs it too, and needs it before the first print, so it
runs at module scope rather than in the lifespan hook.
Verified: uvicorn with no PYTHONIOENCODING, and an import under a stdout
forced to cp1252/strict. Both start and log the emoji correctly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiYkHKB7Tp7X6NdnEutda2
This commit is contained in:
parent
362fe661f9
commit
df0bc19df2
1 changed files with 16 additions and 0 deletions
16
app.py
16
app.py
|
|
@ -64,6 +64,22 @@ MIN_SOURCE_SECONDS = int(os.environ.get("MIN_SOURCE_SECONDS", "45"))
|
||||||
QUALITY_PROBE_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "quality_probe.py")
|
QUALITY_PROBE_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "quality_probe.py")
|
||||||
DISABLE_YOUTUBE_URL = os.environ.get("DISABLE_YOUTUBE_URL", "false").lower() in ("1", "true", "yes")
|
DISABLE_YOUTUBE_URL = os.environ.get("DISABLE_YOUTUBE_URL", "false").lower() in ("1", "true", "yes")
|
||||||
|
|
||||||
|
# Every log line in this module is emoji-prefixed, and a Windows console is
|
||||||
|
# cp1252 by default. _recover_jobs_from_disk() prints one during startup, so
|
||||||
|
# without this the server dies before it ever listens:
|
||||||
|
#
|
||||||
|
# UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1
|
||||||
|
# ERROR: Application startup failed. Exiting.
|
||||||
|
#
|
||||||
|
# subtitles._configure_stdio solved this for the transcription path; the server
|
||||||
|
# needs it too, and needs it before the first print.
|
||||||
|
for _stream in (sys.stdout, sys.stderr):
|
||||||
|
if hasattr(_stream, "reconfigure"):
|
||||||
|
try:
|
||||||
|
_stream.reconfigure(encoding="utf-8", errors="replace")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# ---- Cloud billing (paid / managed-keys) integration --------------------------
|
# ---- Cloud billing (paid / managed-keys) integration --------------------------
|
||||||
# All paid-mode code lives in the optional `cloud/` package and is imported ONLY
|
# All paid-mode code lives in the optional `cloud/` package and is imported ONLY
|
||||||
# when BILLING_ENABLED is set. With the flag off, the app behaves exactly as the
|
# when BILLING_ENABLED is set. With the flag off, the app behaves exactly as the
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue