mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #788] [CLOSED] serve: tolerate broken stdin pipes during engine cleanup #2828
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#2828
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/788
Author: @siddolo
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:fix/serve-broken-pipe-shutdown📝 Commits (1)
2a8e5a4serve: tolerate broken stdin pipes during engine cleanup📊 Changes
2 files changed (+40 additions, -1 deletions)
View changed files
📝
serve/server.py(+4 -1)📝
serve/test_lifecycle.py(+36 -0)📄 Description
Problem
StrataEngine.close()can raiseBrokenPipeErrorfrom itsfinallyblock when closing buffered stdin after the native engine has exited. Closing the stream may flush pending data again, even if an earlierflush()failure was already handled.This was observed on Linux when stopping a custom systemd unit with
KillMode=control-group, where the Python server and native engine receive SIGTERM together. The exception interrupts cleanup before stdout and the log are closed and the engine state is reset, causing an otherwise completed stop to exit with an error.Changes
OSErrorfrom the final stdin close once the process has exited, allowing the remaining cleanup to finish.The existing QUIT -> terminate -> kill sequence, EOF-before-wait behavior, and
EngineStuckhandling are preserved.Validation
Both regression subcases fail with
BrokenPipeErroron the unmodified upstream code and pass with this fix. Validation was run on Linux with Python 3.12.3; the optionaljsonschema>=4.23,<5dependency was installed for the schema tests.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.