From b4a8f264e19029ba27c81f124088588ca9bbf5a4 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 21 Dec 2022 15:14:43 +0000 Subject: [PATCH] Add timeout on FlareRequest --- pynyaata/flarerequests.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pynyaata/flarerequests.py b/pynyaata/flarerequests.py index e339ab9..0231086 100644 --- a/pynyaata/flarerequests.py +++ b/pynyaata/flarerequests.py @@ -1,12 +1,12 @@ from urllib import parse from requests import RequestException, Session, post -from .config import CLOUDPROXY_ENDPOINT +from .config import CLOUDPROXY_ENDPOINT, REQUESTS_TIMEOUT class FlareRequests(Session): - def request(self, method, url, params, **kwargs): + def request(self, method, url, params, timeout=REQUESTS_TIMEOUT, **kwargs): if not CLOUDPROXY_ENDPOINT: - return super().request(method, url, params, **kwargs) + return super().request(method, url, params, timeout=timeout, **kwargs) sessions = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"}).json() @@ -29,6 +29,7 @@ class FlareRequests(Session): "session": FLARESESSION, "url": url, "postData": parse.urlencode(params), + "maxTimeout": timeout, }, ) solution = response.json() @@ -43,7 +44,8 @@ class FlareRequests(Session): raise RequestException(response) except RequestException: session = post( - CLOUDPROXY_ENDPOINT, {"cmd": "sessions.destroy", "session": FLARESESSION} + CLOUDPROXY_ENDPOINT, + {"cmd": "sessions.destroy", "session": FLARESESSION}, ) raise RequestException(solution)