fix: retry transient SSL/connection errors in alert backends

Add retry loop (3 attempts, exponential backoff) for SSLError,
ConnectionError, TimeoutError, and OSError in alert poll cycle.
Non-transient errors fail immediately. Also fixes searx test
mocks to match direct urlopen usage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-15 18:51:28 +01:00
parent f046cced28
commit 6d86e8d7f8
2 changed files with 20 additions and 8 deletions

View File

@@ -1220,7 +1220,7 @@ class TestSearchSearx:
def close(self):
pass
with patch.object(_mod, "_urlopen", return_value=FakeResp()):
with patch("urllib.request.urlopen", return_value=FakeResp()):
results = _search_searx("test query")
assert len(results) == 3
assert results[0]["id"] == "https://example.com/sx1"
@@ -1237,13 +1237,13 @@ class TestSearchSearx:
def close(self):
pass
with patch.object(_mod, "_urlopen", return_value=FakeResp()):
with patch("urllib.request.urlopen", return_value=FakeResp()):
results = _search_searx("nothing")
assert results == []
def test_http_error_propagates(self):
import pytest
with patch.object(_mod, "_urlopen", side_effect=ConnectionError("fail")):
with patch("urllib.request.urlopen", side_effect=ConnectionError("fail")):
with pytest.raises(ConnectionError):
_search_searx("test")