aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-10 15:07:04 +0100
committerGravatar jesopo2018-10-10 15:07:04 +0100
commit951c315cecab43608dd4131c8f444b439d930e98 (patch)
treef57e136f87c4d10efb56be8f2ada66883c2ca239 /src/utils
parent.decode plaintext returns from utils.http.get_url (diff)
signature
Fix syntax error for throwing a timeout when signal.alarm fires
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/http.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/utils/http.py b/src/utils/http.py
index 8ff4ac32..9176fe20 100644
--- a/src/utils/http.py
+++ b/src/utils/http.py
@@ -15,6 +15,8 @@ class HTTPTimeoutException(HTTPException):
class HTTPParsingException(HTTPException):
pass
+def throw_timeout():
+ raise HTTPTimeoutException()
def get_url(url, method="GET", get_params={}, post_data=None, headers={},
json_data=None, code=False, json=False, soup=False, parser="lxml"):
@@ -27,7 +29,7 @@ def get_url(url, method="GET", get_params={}, post_data=None, headers={},
if not "User-Agent" in headers:
headers["User-Agent"] = USER_AGENT
- signal.signal(signal.SIGALRM, lambda: raise TimeoutError())
+ signal.signal(signal.SIGALRM, throw_timeout)
signal.alarm(5)
try:
response = requests.request(