fix(web_server): preserve action exit code after reaping zombie proc
Follow-up on the zombie-reap fix: once the Popen handle is reaped and
dropped from _ACTION_PROCS, migrate the exit code/pid into _ACTION_RESULTS
so subsequent /api/actions/{name}/status polls keep reporting the real
result instead of falling back to None. The dashboard polls repeatedly,
so without this the status flips from 'exited N' to 'unknown' on the
next poll.
This commit is contained in:
parent
866d54a41c
commit
f1e27d8138
@ -1698,6 +1698,10 @@ async def get_action_status(name: str, lines: int = 200):
|
||||
except Exception:
|
||||
pass
|
||||
_ACTION_PROCS.pop(name, None)
|
||||
# Preserve the result so subsequent polls keep reporting the real
|
||||
# exit code/pid instead of falling back to None once the handle
|
||||
# is gone.
|
||||
_ACTION_RESULTS[name] = {"exit_code": exit_code, "pid": pid}
|
||||
|
||||
return {
|
||||
"name": name,
|
||||
|
||||
@ -854,8 +854,18 @@ class TestWebServerEndpoints:
|
||||
# The proc should have been reaped and removed.
|
||||
assert waited, "proc.wait() was not called"
|
||||
assert name not in web_server._ACTION_PROCS
|
||||
|
||||
# A second poll, after the handle is gone, must still report the
|
||||
# real exit code/pid from _ACTION_RESULTS rather than None.
|
||||
status2 = self.client.get(f"/api/actions/{name}/status")
|
||||
assert status2.status_code == 200
|
||||
data2 = status2.json()
|
||||
assert data2["running"] is False
|
||||
assert data2["exit_code"] == 0
|
||||
assert data2["pid"] == 99999
|
||||
finally:
|
||||
web_server._ACTION_PROCS.pop(name, None)
|
||||
web_server._ACTION_RESULTS.pop(name, None)
|
||||
|
||||
def test_get_status_filters_unconfigured_gateway_platforms(self, monkeypatch):
|
||||
import gateway.config as gateway_config
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user