fix(windows): patch platform._syscmd_ver to survive non-UTF-8 output under PEP 540 - #69522
fix(windows): patch platform._syscmd_ver to survive non-UTF-8 output under PEP 540#69522webtecnica wants to merge 2 commits into
Conversation
…large contexts (NousResearch#69424) Three-pronged fix for the stale-stream detector killing connections before a slow local/cloud model finishes prompt prefill: 1. Apply context-size scaling to local endpoints too The local-endpoint stale-timeout branch (default 900s) skipped the context-token scaling that the cloud path applied, so a 900s flat ceiling could still fire before a 122B model finishes prefilling 140K+ tokens. Move scaling out of the branch so both local and cloud paths get proportional timeouts: - >200K tokens → 1800s (30 min) - >100K tokens → 1200s (20 min) - >50K tokens → 600s (10 min) 2. Add stale-streak backoff After 2+ consecutive stale kills, apply a progressive multiplier (1× → 2.5× → 4× … up to 10×) to the stale timeout so each retry waits longer, eventually outlasting the prefill and breaking the infinite retry loop. Resets on successful response. 3. Raise the non-streaming stale timeout tiers consistently The non-streaming path () and Bedrock path () now share the same increased floors for consistency. Closes NousResearch#69424.
…under PEP 540 On Windows with PYTHONUTF8=1 (PEP 540 UTF-8 mode), platform._syscmd_ver() calls subprocess.check_output(..., text=True, encoding='locale', shell=True) to run the Windows 'ver' command. Under PEP 540, locale.getencoding() returns 'utf-8', but the 'ver' command emits output in the system's active ANSI code page (cp1252 on US-English). Bytes that are valid in cp1252 but not in UTF-8 — e.g. 0xe9 (é) — raise a UnicodeDecodeError inside the subprocess reader thread. The patch wraps platform._syscmd_ver with a try/except that catches UnicodeDecodeError and gracefully returns input defaults, matching the existing OSError/CalledProcessError fallback that _win32_ver already handles. Fixes NousResearch#69413
|
Triage evidence only (not a merge decision): this PR currently contains commit |
|
Closing after a deep verification pass — the diagnosis deserves a detailed response because the issue you chased is partially real. What's correct: on Python 3.11.0/3.11.1, Why this PR couldn't merge as-is: (1) the wrapper's What shipped instead (PR #71014): the existing full-stub |
Fixes #69413
Description
On Windows, the OpenAI SDK generates platform headers by calling
platform.platform(). This triggers:When
PYTHONUTF8=1(PEP 540 UTF-8 mode) is active — which Hermes sets on Windows —locale.getencoding()returns"utf-8". However, the Windowsvercommand outputs text in the system's active ANSI code page (e.g.cp1252on US-English). Bytes that are valid in cp1252 but not in UTF-8 — such as0xe9(é in cp1252, an invalid UTF-8 start byte) — raiseUnicodeDecodeErrorinside the subprocess reader thread.Fix
Added
_patch_platform_syscmd_ver()tohermes_bootstrap.pythat wrapsplatform._syscmd_verwith atry/except UnicodeDecodeErroron Windows. When thevercommand output can't be decoded as UTF-8, the patched function gracefully returns its input defaults.Applied automatically on module import (every Hermes entry point already imports
hermes_bootstrapfirst). No-op on POSIX.Changes
hermes_bootstrap.py_patch_platform_syscmd_ver()function + module-level calltests/test_hermes_bootstrap.pyTestPatchPlatformSyscmdVerclass (5 tests)Test results
All 23 tests pass, 5 Windows-only skipped on Linux.
Closes #69413