mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3241] [CLOSED] [TUI] serve: keepawake primes its daemon before the first acquire (a fast request could miss the hold) #4520
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#4520
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/3241
Author: @Buddychek
Created: 10/19/2026
Status: ❌ Closed
Base:
main← Head:fix/keepawake-start-race📝 Commits (1)
acffabbserve: keepawake primes its daemon before the first acquire - a request that finishes before the thread exists (acquire then release) lost the transient count>0 transition and never held; the loop signals it has entered and acquire waits for that. Same root cause as the test-side fixture in #1901, fixed in the runtime. serve/test_keepawake.py 6/6 OK on Windows, no real power API called📊 Changes
1 file changed (+10 additions, -0 deletions)
View changed files
📝
serve/keepawake.py(+10 -0)📄 Description
Problem and result
serve/keepawake.pystarts its daemon thread lazily. A request that finishes before the thread exists (acquire then release, a fast request) lost the transientcount > 0transition, so the machine-sleep hold never engaged: the server answered the request and the PC could sleep mid-session.After: the loop signals it has entered and
acquirewaits for that, so the first acquire can no longer race the thread start. Same root cause as the test-side fixture in #1901, fixed in the runtime.Related discussion
Closed in the 0.2.0-beta tracker reset; rebased on main and re-verified per the reset note. #1901 fixed the same race on the test side.
Approach
The daemon loop sets an "entered" event as its first act;
acquirewaits for that event before counting, so the count>0 transition is always observed.Validation
Passed, rebased on 0.2.0-beta main (
e88ee39d):python -m unittest serve.test_keepawake→ 6/6 OK, exit 0. Windows 11, Python 3.15; no real power API called.Not run: real suspend/resume on battery; CI.
Limits
Windows keepawake path only; the fix adds a startup handshake, no change to the power API calls themselves.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.