test: clean up concurrent cooldown processes
This commit is contained in:
@@ -137,9 +137,9 @@ def test_check_and_reserve_atomic_under_concurrent_access(tmp_path: Path) -> Non
|
||||
import multiprocessing
|
||||
|
||||
state_file = tmp_path / "concurrent.json"
|
||||
results = multiprocessing.Manager().list()
|
||||
|
||||
# Launch 3 processes simultaneously
|
||||
# Explicitly shut down the manager and never leak a timed-out child.
|
||||
with multiprocessing.Manager() as manager:
|
||||
results = manager.list()
|
||||
processes = []
|
||||
for i in range(3):
|
||||
args = (i, str(state_file), results)
|
||||
@@ -149,6 +149,10 @@ def test_check_and_reserve_atomic_under_concurrent_access(tmp_path: Path) -> Non
|
||||
p.start()
|
||||
for p in processes:
|
||||
p.join(timeout=10)
|
||||
for p in processes:
|
||||
if p.is_alive():
|
||||
p.terminate()
|
||||
p.join(timeout=2)
|
||||
|
||||
# At most one should succeed
|
||||
ok_count = sum(1 for _, r in results if r == "ok")
|
||||
|
||||
Reference in New Issue
Block a user