Fail safe, not dead: bound the HID cancel wait, isolate sensor failures, keep the fan worker alive
- hid.py: after a timed-out HID operation, wait at most 1 s for the driver to finish the cancelled IRP; if it does not, mark the channel broken so the caller's reconnect path closes it instead of blocking forever on a wedged device. Keep abandoned OVERLAPPED/buffer references alive until close so a late IRP completion cannot write into reused memory. Check CreateEventW. - telemetry/service.py: read each source (CPU, GPU, system power, GPU memory) independently; a failing source now costs only its own readings instead of the whole sample, logged at most once a minute per source. - sensors.py: the Commander PRO iCUE ownership check runs inside a guard; if ownership cannot be established the device is released rather than risking swapped replies (and the failure no longer escapes into the sample). - cooling/control.py: an unexpected exception no longer ends fan control for the life of the process; fail safe, log at most once a minute, retry with a fresh sensor object after 5 s. failsafe() no longer raises, and control errors back off 5 s instead of re-opening the device every second.
This commit is contained in:
1 parent
7356809c0a
commit
d637d46777
5 files changed
+102
-26
No files matched your search
@@ -238,15 +238,25 @@ class FanWorkerTest(unittest.TestCase):
|
||||
self.commander.set_duty.assert_called_once_with((4, 5, 6), 100)
|
||||
self.commander.close.assert_called_once()
|
||||
|
||||
def test_worker_error_is_visible_and_attempts_failsafe(self):
|
||||
def test_worker_survives_unexpected_errors_and_keeps_failing_safe(self):
|
||||
stop = threading.Event()
|
||||
gpu = Mock()
|
||||
gpu.read.side_effect = RuntimeError("sensor failure")
|
||||
with patch("kurgan.cooling.control.GpuSensors", return_value=gpu):
|
||||
reads = []
|
||||
|
||||
def read():
|
||||
reads.append(1)
|
||||
if len(reads) >= 3:
|
||||
stop.set()
|
||||
raise RuntimeError("sensor failure")
|
||||
|
||||
gpu.read.side_effect = read
|
||||
with patch("kurgan.cooling.control.GpuSensors", return_value=gpu), \
|
||||
patch.object(CaseFanControl, "ERROR_RETRY_SECONDS", 0):
|
||||
with self.assertLogs("kurgan.cooling.control", level="ERROR"):
|
||||
self.control.run(stop)
|
||||
self.assertEqual(len(reads), 3) # retried instead of dying on the first error
|
||||
self.assertIn("CONTROL ERROR", self.control.status)
|
||||
self.commander.set_duty.assert_called_once_with((4, 5, 6), 100)
|
||||
self.commander.set_duty.assert_called_with((4, 5, 6), 100)
|
||||
|
||||
|
||||
class CommanderControlTest(unittest.TestCase):
|
||||
|
||||
Reference in new issue
Block a user