fix(media): Circuit-Breaker für D-Bus-Connect-Fehler
Nach dem ersten fehlgeschlagenen Bus-Connect wird der Controller dauerhaft deaktiviert, statt bei jedem Hotkey-Druck einen neuen Connect-Versuch zu starten. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -173,3 +173,27 @@ async def test_pause_is_noop_when_bus_unreachable(monkeypatch, caplog):
|
||||
assert controller._paused == []
|
||||
assert any("D-Bus" in r.message or "bus" in r.message.lower()
|
||||
for r in caplog.records)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pause_skips_reconnect_after_bus_failure(monkeypatch):
|
||||
"""Bus-Connect-Fehler darf nicht bei jedem Aufruf erneut versucht werden."""
|
||||
from whisper_local.media._mpris import MprisController
|
||||
|
||||
connect_calls = 0
|
||||
|
||||
async def failing_connect(self):
|
||||
nonlocal connect_calls
|
||||
connect_calls += 1
|
||||
raise RuntimeError("no session bus")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"dbus_next.aio.MessageBus.connect", failing_connect, raising=False
|
||||
)
|
||||
controller = MprisController()
|
||||
|
||||
await controller.pause()
|
||||
await controller.pause()
|
||||
await controller.pause()
|
||||
|
||||
assert connect_calls == 1
|
||||
|
||||
Reference in New Issue
Block a user