From e1dba62bf29f01c498e2e013f5b96fb4260af2dc Mon Sep 17 00:00:00 2001 From: Ben Brady Date: Mon, 9 Mar 2026 13:55:48 +0000 Subject: [PATCH] added timeout option --- rule34Py/rule34.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rule34Py/rule34.py b/rule34Py/rule34.py index f3d797b..0096099 100644 --- a/rule34Py/rule34.py +++ b/rule34Py/rule34.py @@ -76,6 +76,8 @@ class rule34Py: captcha_clearance: Union[str, None] = os.environ.get("R34_CAPTCHA_CLEARANCE", None) #: The ``requests.Session`` object used when the client makes HTML requests. session: requests.Session = None + #: The ``timeout`` option passed to session.get + timeout: None | (int | float) | tuple[(int | float), (int | float)] = 2.5 * 60 #: The ``User-Agent`` HTML header value used when the client makes HTML requests. #: Defaults to either the value of the ``R34_USER_AGENT`` environment variable; or the ``rule34Py.rule34.DEFAULT_USER_AGENT``, if not asserted. #: Can be overridden by the user at runtime to change User-Agents. @@ -156,6 +158,9 @@ def _get(self, *args, **kwargs) -> requests.Response: if self.captcha_clearance is not None: kwargs["cookies"]["cf_clearance"] = self.captcha_clearance + # timeout + kwargs["timeout"] = self.timeout + return self.session.get(*args, **kwargs) def get_comments(self, post_id: int) -> list[PostComment]: