mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-29 18:03:26 +01:00
Research tick survives pacman timeouts
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Under load pacman -Qi / iptables exceed their 10 s timeouts inside the research-window pass; the uncaught TimeoutExpired crashed the daemon (systemd restart loop). The pass now logs and retries next tick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5d5aa3e773
commit
c1f0562995
@ -19,6 +19,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from dataclasses import replace
|
from dataclasses import replace
|
||||||
import logging
|
import logging
|
||||||
|
import subprocess
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from leisure_watch.procscan import LAUNCHER_PROCESS_NAMES, kill_target_names
|
from leisure_watch.procscan import LAUNCHER_PROCESS_NAMES, kill_target_names
|
||||||
@ -100,7 +101,12 @@ def total_block_pass(config: Config) -> None:
|
|||||||
at = window.now()
|
at = window.now()
|
||||||
record = window.live_record(at)
|
record = window.live_record(at)
|
||||||
if record is not None and record.is_open(at):
|
if record is not None and record.is_open(at):
|
||||||
|
# A loaded machine can push pacman/iptables past their timeouts; that
|
||||||
|
# costs this tick (the next one retries), never the daemon.
|
||||||
|
try:
|
||||||
_research_pass(record)
|
_research_pass(record)
|
||||||
|
except OSError, subprocess.SubprocessError:
|
||||||
|
logger.exception("Research window pass failed; retrying next tick")
|
||||||
return
|
return
|
||||||
if record is not None and not record.closed and at >= record.until:
|
if record is not None and not record.closed and at >= record.until:
|
||||||
record = _latch_closed(record)
|
record = _latch_closed(record)
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from steam_backlog_enforcer import _research_record as store
|
from steam_backlog_enforcer import _research_record as store
|
||||||
from steam_backlog_enforcer import _research_window as window
|
from steam_backlog_enforcer import _research_window as window
|
||||||
from steam_backlog_enforcer import config as cfg
|
from steam_backlog_enforcer import config as cfg
|
||||||
@ -106,3 +110,24 @@ class TestOpenWindow:
|
|||||||
run_pass()
|
run_pass()
|
||||||
assert cfg.STATE_FILE.read_bytes() == before
|
assert cfg.STATE_FILE.read_bytes() == before
|
||||||
assert tm.enforce.call_args.args[0] == {window.LIBRARIAN_APP_ID}
|
assert tm.enforce.call_args.args[0] == {window.LIBRARIAN_APP_ID}
|
||||||
|
|
||||||
|
|
||||||
|
class TestSlowSystem:
|
||||||
|
"""A command that times out costs one tick, never the daemon."""
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"error",
|
||||||
|
[subprocess.TimeoutExpired(["pacman", "-Qi", "steam"], 10), OSError("busy")],
|
||||||
|
)
|
||||||
|
def test_failed_reconcile_is_retried_next_tick(
|
||||||
|
self, tm: Mocks, error: Exception
|
||||||
|
) -> None:
|
||||||
|
"""Test that a timed-out pacman/iptables call does not crash the loop."""
|
||||||
|
tm.reconcile.side_effect = error
|
||||||
|
window.write_record(make_record())
|
||||||
|
run_pass()
|
||||||
|
tm.block_tick.assert_not_called()
|
||||||
|
tm.enforce.assert_not_called()
|
||||||
|
tm.reconcile.side_effect = None
|
||||||
|
run_pass()
|
||||||
|
tm.enforce.assert_called_once()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user