mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1883] [Engine] serve: on Windows the engine and the image encoder start without a console window of their own #3736
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#3736
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/1883
Author: @LeGeRyChEeSe
Created: 10/10/2026
Status: 🔄 Open
Base:
main← Head:pr/windows-no-console📝 Commits (1)
903dbceserve: on Windows the engine and the image encoder start without a console window of their own, so a server started without a console (pythonw, a service, a launcher that hides it) opens none📊 Changes
2 files changed (+19 additions, -1 deletions)
View changed files
📝
serve/server.py(+5 -1)📝
serve/test_server.py(+14 -0)📄 Description
Problem and result
When the server has no console - started with
pythonw, as a service, or by a launcher that hides it - Windows gives each console program it starts a new, visible console window: one forstrata.exe, one for the image encoder, again at every engine restart. Their output already goes through pipes and the log, so the window is empty, and closing it by mistake ends the engine. This still happens on v0.2.2.After the change the engine and the image encoder start without a console window of their own.
Related discussion
No open issue or pull request found (searched 2026-10-22: "console window", "CREATE_NO_WINDOW", "pythonw").
This pull request was closed in the 0.2.0-beta tracker reset; it is rebased on v0.2.4.1. The only change since the first version is in the test (see Validation):
serve/lifeline.pynow adds its own creation flag.Approach
popen()(the #735 wrapper both children use) now setscreationflags=CREATE_NO_WINDOWon Windows when the caller gave none, asserve/mcp.pyalready does for MCP servers. A caller's owncreationflagswins. The lifeline then addsCREATE_NEW_PROCESS_GROUPfor the isolated roles, so the child gets both flags. Nothing changes on other systems, and nothing changes for a server started from a console (the child's console was the parent's, and its I/O is redirected). The job object ofserve/winjob.pystill ties the children to the server's lifetime.Validation
Revision:
main8183c6b6(v0.2.4.1) plus this one commit; the first runs were on v0.2.2 (011c9e60). Environment: Windows 11, Python 3.13, RTX 4070 SUPER.Passed:
main8183c6b6(v0.2.4.1):python -m unittest serve.test_serverpasses (353 tests, 3 skipped, Windows 11).subprocess.CREATE_NO_WINDOWread on a platform that does not define it); the last assertion now reads the flag withgetattr, as the code does.pythonw.exeparent starts a console child that printsGetConsoleWindow().subprocess.Popen: non-zero handle (a window);serve.server.popen()on v0.2.2 without the change: non-zero handle (a window, observed263400);serve.server.popen()with the change:0(no window).python -m pytest serve -qon this branch: 913 passed, 17 skipped.test_no_console_window_on_windowschecks that the flag is set on Windows, absent elsewhere, and that a caller's own flags are kept. It tests the flag as a bit rather than by equality, because the lifeline addsCREATE_NEW_PROCESS_GROUPto the same field.Failed:
none observed.
Not run:
os.name == "nt".pythonwparent was tried.Limits
Windows only. A console program that is started by something other than
popen()is not covered.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.