Skip to content

Commit b7c4a14

Browse files
committed
improve(images): add timeout to remote images requests
1 parent 8566add commit b7c4a14

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mkdocs_rss_plugin/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ def get_remote_image_length(
656656
image_url: str,
657657
http_method: str = "HEAD",
658658
attempt: int = 0,
659+
req_timeout: tuple[float, float] = (5, 30),
659660
ssl_verify: bool = True,
660661
) -> Optional[int]:
661662
"""Retrieve length for remote images (starting with 'http').
@@ -668,6 +669,8 @@ def get_remote_image_length(
668669
http_method (str, optional): HTTP method to use for the request.
669670
Defaults to "HEAD".
670671
attempt (int, optional): request tries counter. Defaults to 0.
672+
req_timeout (tuple[float, float], optional): (connect, read) timeout in \
673+
secondes. Defaults to (5, 30).
671674
ssl_verify (bool, optional): option to perform SSL verification or not.
672675
Defaults to True.
673676
@@ -686,7 +689,7 @@ def get_remote_image_length(
686689
)
687690
req_response = self.req_session.request(
688691
method=http_method,
689-
timeout=(3.05, 10), # (connect, read) timeout in secondes
692+
timeout=req_timeout,
690693
url=image_url,
691694
verify=ssl_verify,
692695
)

0 commit comments

Comments
 (0)