mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2043] [CLOSED] serve: fix potential race in NoLeakedSampler during test runs #3824
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#3824
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/2043
Author: @clothespin
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:test-responses-sampler-race📝 Commits (1)
a864f79serve: fix potential race in NoLeakedSampler during test runs📊 Changes
1 file changed (+7 additions, -8 deletions)
View changed files
📝
serve/test_responses.py(+7 -8)📄 Description
Title
Issue: none of its own. The flake was noted as pre-existing in the validation notes of #1327, #1563, #1840 and #2023;
#1840 fixed it for its own new test file only.
Summary
NoLeakedSampler.test_server_close_ends_the_samplerinserve/test_responses.pyfails now and then withAssertionError: 1 != 2(serve/test_responses.py:284). The server is not leaking anything; the test was countinganother test's thread. This changes the test only.
serve/code is unchanged.What changed
serve/test_responses.py(+7 -8).The test counted every thread in the process whose name ends in "(_loop)".
Telemetry.close()(
serve/telemetry.py:420) only sets the stop flag, so the sampler of a server an earlier test closed can still betaking its last reading when this test starts. The count before
serve()is then 1, that thread ends while the newserver starts, and the count after is 1, not 2.
The test now notes the threads alive before
serve()and takes the one new "(_loop)" thread as its own server'ssampler. After
server_close()it waits up to 5 s for that thread to end, the same limit the old loop used.Checked on Linux (Arch, Python from the repo's
.venv):python -m unittest serve.test_responses, 30 runs each: 2 failures before (both this test,1 != 2), 0 after.passes 3 of 3 after.
Telemetry.close()made a no-op, so a server really leaks its sampler: the test fails before and after, so itstill catches the leak it was written for.
python -m unittest discover -s serve -t . -p "test_*.py"): 706 tests, 8 skipped, 1 failure. Thatfailure is
test_keepawake'stest_service_holds_for_the_whole_request_including_early_close, which also fails onunchanged
mainand is the race #1901 fixes.Not run: Windows, macOS.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.