fix: split HTTP connect/read timeouts (Jellyfin build + qBit stats)

Every HTTP client passed an integer timeout to requests, applying the same
value to BOTH connect and read phases. A slow Jellyfin /Items page or qBit
/sync/maindata blew through the 10s read budget → ReadTimeoutError. Split
into a (connect=5s, read=60s default) tuple via shared http_timeout() helper.
The media index build worker uses a 180s read floor. Existing services with
low timeout_seconds benefit from bumping to 60+.
This commit is contained in:
Developer
2026-07-10 11:43:07 +00:00
parent 9bc8fab971
commit 044d386ac7
17 changed files with 152 additions and 29 deletions
+15
View File
@@ -129,6 +129,21 @@ class QbittorrentClientTests(unittest.TestCase):
with self.assertRaises(requests.ConnectionError):
client._login()
def test_qbittorrent_client_uses_tuple_timeout(self) -> None:
"""The client passes a (connect, read) tuple to requests, not an int."""
# self.client was constructed with timeout=5 in setUp() and has a mocked session.
assert isinstance(self.client.timeout, tuple)
assert len(self.client.timeout) == 2
assert self.client.timeout[0] == 5.0 # connect timeout
assert self.client.timeout[1] == 5.0 # read timeout (what we passed)
# Verify it's actually passed to requests as-is.
self.session.post.return_value = self._login_response()
self.client._login()
call_kwargs = self.session.post.call_args.kwargs
assert call_kwargs["timeout"] == (5.0, 5.0)
assert not isinstance(call_kwargs["timeout"], int)
if __name__ == "__main__":
unittest.main()