mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1862] [CLOSED] serve: Ctrl+C prints "Exception ignored in: <_io.TextIOWrapper ...>" from the vision encoder's buffered QUIT #3724
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3724
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1862
Author: @weituotian
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:fix/vision-stdin-close📝 Commits (1)
bebd01dserve: close the vision encoder's stdin in close(), so its buffered QUIT is not flushed by the GC📊 Changes
1 file changed (+9 additions, -0 deletions)
View changed files
📝
serve/server.py(+9 -0)📄 Description
Stopping the server with Ctrl+C, with an image encoder configured (
"vision"in the config), prints two lines of Python noise between[strata] stoppingand[strata] stopped:The model stops correctly and the shell prompt comes back - the shutdown itself is fine, it is only the report. But it names a line of our own code at every stop, which reads like a crash.
Why it happens
Vision.close()writesQUITinto the encoder's stdin and then drops the process:The pipes are made with
text=True, bufsize=1, so the newline flushes insidewrite(). Ctrl+C reaches every process attached to the console, so the encoder can already be gone by then, and that flush raisesOSError [Errno 22]- the existingexcept Exceptioncatches it, so the shutdown carries on. ButQUITis then still in theTextIOWrapper's buffer. Whenprocgoes out of scope at the end ofclose(), the wrapper's finalizer flushes it again, raises the sameOSError, and CPython prints it asException ignored in: <_io.TextIOWrapper name=4 ...>, with the caller's frame (shutdown, theself.close()line) - exactly the two lines above.StrataEngine.close()has never shown this, because it already closes its stdin and ignores the error, with a comment that names this very case:(serve/server.py:1863). The encoder's
close()never got the same guard. That is the whole of this PR.Minimal reproduction, no model and no GPU needed
Windows 11 26100, CPython 3.13.14:
Arm A, as the code is today:
Arm B, with the pipes closed here and the error ignored: the
close()raises the same[Errno 22], it is swallowed, the wrapper is marked closed, and the GC prints nothing at all.On a real server
ready:.[strata] stoppingand[strata] stopped; the fix removes them.Without a
"vision"section the lines never appear in the first place - onlyvision.shutdownis in the closer list, which is why this went unnoticed for so long.The change
Nine lines at the end of
Vision.close()(serve/server.py:2164-2172): close the encoder's stdin there, ignoringOSError, the wayStrataEngine.close()already does.What it leaves alone
QUIT, the samewait(10), the samekill, the samewait.QUITleaves the buffer empty, so the addedclose()is a no-op there.serve/server.py.How it was checked
python -m unittest discover -s serve -t . -p "test_*.py"on this branch rebased onto61b3fb5d: 690 tests, OK (11 skipped).Caveats
"gpu": false). No Linux run. The mechanism is not Windows-specific (SIGINT goes to the whole process group there too, and the second flush would raiseBrokenPipeErrorinstead), but I have not reproduced it on Linux and this PR does not claim it.TextIOWrapperandException ignoredfind nothing, so this is a new thread rather than a reply to an existing one (#352 and #1317 are about the encoder's pipe in other ways, #181 about ending the processes with the server).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.