unsloth/studio/backend
Daniel Han bdf51525ea
Studio: make Stop and stall deadlines interrupt a wedged stream portably (#7236)
* Studio: make Stop and stall deadlines interrupt a wedged stream portably

The cancel watcher unblocks a stalled read by shutting the socket down from
another thread, which works on POSIX but not reliably on native Windows, where
Winsock does not dependably wake a recv() already in progress on another thread.
Wrap the httpcore network stream so the reader loops each read in short slices
and polls the cancel event itself. Stop and the stall deadlines now interrupt a
wedged mid-stream read without any cross-thread socket teardown, and a slow but
still-alive stream is never torn down. The POSIX shutdown path is preserved.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Honor the post-first-token stall timeout in the cancel-aware read

httpcore snapshots request.extensions timeout read once when the body
starts, so lowering it to the stall timeout after the first token never
reached the socket read and a one-token-then-silent server hung for the
full prefill window. Re-read the live extensions timeout per call and
bound each read by it, falling back to the httpcore-passed timeout when
absent so prefill and normal completion are unchanged.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* studio: tighten comments in the llama.cpp stall timeout path

* Tighten comments in the stream stall cancel path

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <unslothshared@gmail.com>
2026-07-20 05:29:18 -07:00
..
assets Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
auth Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
core Studio: make Stop and stall deadlines interrupt a wedged stream portably (#7236) 2026-07-20 05:29:18 -07:00
hub Studio: hide the RAG embedder and llama.cpp probe from the hub cached inventory (#7018) 2026-07-19 03:20:56 -07:00
loggers Studio: quiet noisy logs, log real progress, and speed up Windows/macOS dataset prep (#7087) 2026-07-15 06:49:52 -07:00
models Studio: GPU memory configuration for GGUF models (#6414) 2026-07-19 05:46:22 -07:00
plugins Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
requirements Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
routes Studio: Data settings tab, uploaded files manager, quant pinning, and chat image preview fix (#7029) 2026-07-20 04:57:44 -07:00
state Studio: shareable per-checkpoint preview links (#6486) 2026-06-24 06:31:53 -07:00
storage Studio: Data settings tab, uploaded files manager, quant pinning, and chat image preview fix (#7029) 2026-07-20 04:57:44 -07:00
tests Studio: make Stop and stall deadlines interrupt a wedged stream portably (#7236) 2026-07-20 05:29:18 -07:00
utils Studio: fix per-GPU VRAM reporting on Windows ROCm (#7238) 2026-07-20 05:27:53 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_platform_compat.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
cloudflare_tunnel.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
colab.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
main.py Studio: fix per-GPU VRAM reporting on Windows ROCm (#7238) 2026-07-20 05:27:53 -07:00
mcp_server.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
run.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
startup_banner.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00