Add timeout on FlareRequest
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
beead16617
commit
b4a8f264e1
@ -1,12 +1,12 @@
|
|||||||
from urllib import parse
|
from urllib import parse
|
||||||
from requests import RequestException, Session, post
|
from requests import RequestException, Session, post
|
||||||
from .config import CLOUDPROXY_ENDPOINT
|
from .config import CLOUDPROXY_ENDPOINT, REQUESTS_TIMEOUT
|
||||||
|
|
||||||
|
|
||||||
class FlareRequests(Session):
|
class FlareRequests(Session):
|
||||||
def request(self, method, url, params, **kwargs):
|
def request(self, method, url, params, timeout=REQUESTS_TIMEOUT, **kwargs):
|
||||||
if not CLOUDPROXY_ENDPOINT:
|
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()
|
sessions = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"}).json()
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ class FlareRequests(Session):
|
|||||||
"session": FLARESESSION,
|
"session": FLARESESSION,
|
||||||
"url": url,
|
"url": url,
|
||||||
"postData": parse.urlencode(params),
|
"postData": parse.urlencode(params),
|
||||||
|
"maxTimeout": timeout,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
solution = response.json()
|
solution = response.json()
|
||||||
@ -43,7 +44,8 @@ class FlareRequests(Session):
|
|||||||
raise RequestException(response)
|
raise RequestException(response)
|
||||||
except RequestException:
|
except RequestException:
|
||||||
session = post(
|
session = post(
|
||||||
CLOUDPROXY_ENDPOINT, {"cmd": "sessions.destroy", "session": FLARESESSION}
|
CLOUDPROXY_ENDPOINT,
|
||||||
|
{"cmd": "sessions.destroy", "session": FLARESESSION},
|
||||||
)
|
)
|
||||||
|
|
||||||
raise RequestException(solution)
|
raise RequestException(solution)
|
||||||
|
Reference in New Issue
Block a user