The Docling and MinerU model downloads read their child's output with
text=True and no encoding, so the backend decoded it with the ANSI code
page. Under `deeptutor start` the backend gets PYTHONIOENCODING=utf-8
but not UTF-8 mode, so on a cp936/cp932 server the downloader writes
UTF-8 tqdm bars that the pump cannot decode. The first bar raised
UnicodeDecodeError, the pump stopped reading, the child blocked on the
full pipe and the job stayed "running" with an empty log.
Follow the MinerU parse subprocess: run the downloader with
PYTHONUTF8=1 and decode its output as UTF-8 with errors="replace".
* fix: Windows robustness — MinerU UTF-8 decode, render-thread crash & atomic-write PermissionError
- mineru/local.py: pass encoding="utf-8", errors="replace" to subprocess.Popen so MinerU's combined stdout/stderr is decoded as UTF-8 instead of the platform default (GBK on zh-CN Windows), which previously crashed with a UnicodeDecodeError (0x8b).
- mineru/models.py: set MINERU_PDF_RENDER_THREADS=1 in model_env_overrides to avoid MinerU's multi-threaded PDF rendering heap-corruption crash (0xc0000409) on Windows.
- services/file_io.py: retry atomic replace on transient PermissionError (e.g. target locked by antivirus/indexer) with exponential backoff, instead of failing the whole write on Windows.
* fix(mineru): gate the render-thread guard to Windows
`MINERU_PDF_RENDER_THREADS=1` was set unconditionally, but the variable is
honored on Linux and macOS too (upstream default 3-4 render workers), so a
Windows-only heap-corruption workaround was serializing page rendering for
every platform. It also sat in `model_env_overrides`, whose contract is the
model-weight download source — and adding a key there broke that function's
exact-equality test.
Move it to its own `render_env_overrides()` next to the other MinerU env
knowledge, guarded on `sys.platform`, and merge it into the subprocess env at
the local-CLI branch in `backend.py`. Only that branch renders pages in this
process tree; cloud mode never does.
---------
Co-authored-by: Frank <bingxizhao@novix.science>