docs(code-runtime-python): correct the ProtocolChannel serialization docstring

The class docstring still credited the GIL plus per-frame PIPE_BUF atomicity for
serializing writes, which _write_lock's full-write loop already superseded. State
the current contract (writers serialized by _write_lock around a full-write loop)
and drop the double blank line under the binding-replies note heading.
This commit is contained in:
Chinesezjc
2026-08-31 14:21:57 +08:00
committed by Tianyi Cui
parent a8e47dae37
commit 9f449a79a6
3 changed files with 7 additions and 5 deletions
@@ -345,9 +345,12 @@ class ProtocolChannel:
Writes are unbuffered and go straight to the fd, so ``send_sync`` is safe
from inside model code (which may run outside an asyncio task) and from
background tasks alike. The single writer is serialized by CPython's GIL
plus one os.write per frame (POSIX guarantees atomicity for writes below
``PIPE_BUF``, and our frames are short JSON lines).
background tasks alike. Concurrent writers are serialized by ``_write_lock``
around a full-write loop (see ``send_sync``): ``os.write`` releases the GIL,
a frame may exceed ``PIPE_BUF`` (logs up to ``maxLogBytes``, completions up
to ``maxValueBytes``, uncapped ``call`` args), and one ``os.write`` may
consume only part of a frame — so neither the GIL nor per-frame atomicity is
relied on for framing.
"""
def __init__(self, fd: int) -> None: