mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#5181
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/4791
Author: @XiaoBinGan
Created: 10/31/2026
Status: ❌ Closed
Base:
main← Head:fix/close-leaked-handles📝 Commits (1)
74c0f11Fix #4654: close the six handles the sampler and the HIP probe open inside an expression📊 Changes
2 files changed (+18 additions, -8 deletions)
View changed files
📝
serve/server.py(+8 -2)📝
serve/telemetry.py(+10 -6)📄 Description
Problem and result
The
Minimal serving runtimejob prints the sameResourceWarninglines on every run (#4654). Sixopen()calls satinside an expression, so no
close()ever ran:serve/telemetry.py— thephysical_package_idglob (one handle per CPU),/proc/cpuinfo,/proc/stat,/proc/meminfoserve/server.py— the twopropertiesfiles the HIP probe readsEach now runs under a
withstatement (or through a one-line_read_lines()helper for the twopropertiesreads).No value, threshold or return path changes: the same figures are parsed from the same lines in the same order.
Related discussion
#4654 — the report with the exact warning lines and the two sites in
server.py. A pytest run with-W error::ResourceWarningon the CI job is what the report suggests; this PR removes the leaks it names and does notchange the job.
Approach
Only the ownership of the handles changes:
and for the HIP probe:
The early
returninside the cpuinfo loop is kept; thewithcloses the file on the way out, which is the bug thereport describes (
_cpu_name()reports at thereturn, not at theopen()).Validation
Passed:
python -m pytest serve/test_monitor.py -qon this checkout (Python 3.11.16, Windows): 10 passed, 8subtests passed — the module these helpers live in imports and its monitor tests are unchanged.
Passed:
import serve.telemetryandimport serve.serverboth succeed after the change, and a grep for anopen(still inside an expression in
serve/telemetry.pynow finds none.Failed: none.
Not run: the
/procand/sysbranches themselves cannot be exercised on this Windows checkout (they are Linuxpaths), so the warnings the job reports are verified by reading the diff, not by reproducing them here. A Linux run with
-W error::ResourceWarningwould settle it, and the issue's own job is the natural place.Limits
propertiesreads are now one small helper rather than two identical comprehensions; if the reviewer preferspathlib.Path(...).read_text(...)inline, that is a one-line change each.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.