From 035fb8ddc918337fdf6cf9743082aacae940b9db Mon Sep 17 00:00:00 2001 From: Sonja M Thomas Date: Thu, 26 Nov 2026 19:14:20 -0600 Subject: [PATCH] Handle shutdown acknowledgement when the parent exits during polling --- arm/update_worker.py | 6 +++--- tests/test_updates.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arm/update_worker.py b/arm/update_worker.py index 4254ada..817080e 100644 --- a/arm/update_worker.py +++ b/arm/update_worker.py @@ -258,14 +258,14 @@ def wait_parent(data, target, plan_dir, timeout=75): try: parent = psutil.Process(data["parent"]) alive = abs(parent.create_time() - data["created"]) <= 0.01 + if alive and Path(parent.exe()).resolve() != target / EXE: + raise UpdateError("The requesting process is not this Adaptive Resource Monitor installation.") except psutil.NoSuchProcess: alive = False if not alive: - if not acknowledged: + if read_json(plan_dir / "closed.json") != expected: raise UpdateError("ARM exited without confirming that settings and history were closed. Installation stopped.") return - if Path(parent.exe()).resolve() != target / EXE: - raise UpdateError("The requesting process is not this Adaptive Resource Monitor installation.") sleep(.25) raise UpdateError("ARM did not shut down in time. To retry, close any open ARM dialogs and start the update again.") diff --git a/tests/test_updates.py b/tests/test_updates.py index 824f901..c799a83 100644 --- a/tests/test_updates.py +++ b/tests/test_updates.py @@ -189,6 +189,8 @@ class UpdateTests(unittest.TestCase): wait_parent(plan, target, self.work) (self.work / "closed.json").write_text(json.dumps({"pid": 10, "version": VERSION})) wait_parent(plan, target, self.work) + with patch("arm.update_worker.read_json", side_effect=[None, {"pid": 10, "version": VERSION}]): + wait_parent(plan, target, self.work) with patch("arm.update_worker.psutil.Process") as process: process.return_value.create_time.return_value = 1 process.return_value.exe.return_value = str(target / "AdaptiveResourceMonitor.exe")