@@ -42,7 +42,7 @@ def _authenticate(self, email, password):
4242 "email" : email ,
4343 "password" : password ,
4444 }
45- response = requests .post (url , headers = headers , data = data )
45+ response = requests .post (url , headers = headers , data = data , timeout = 10 )
4646
4747 if response .status_code == 200 :
4848 return {"code" : 200 , "cookies" : response .cookies }
@@ -65,7 +65,7 @@ def _get_threads_in_forum_category(self, category_name, page):
6565 "data" : {"posts" : [], "users" : []},
6666 }
6767
68- response = requests .get (url , headers = headers )
68+ response = requests .get (url , headers = headers , timeout = 10 )
6969 data = response .json ()
7070
7171 # Page out of range.
@@ -84,7 +84,7 @@ def get_profile(self):
8484 headers = {
8585 "User-Agent" : USER_AGENT ,
8686 }
87- response = requests .get (url , headers = headers , cookies = self ._cookies )
87+ response = requests .get (url , headers = headers , cookies = self ._cookies , timeout = 10 )
8888
8989 if response .status_code == 200 :
9090 return {
@@ -108,7 +108,12 @@ def search(self, query):
108108 "User-Agent" : USER_AGENT ,
109109 "Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8" ,
110110 }
111- response = requests .post (url , headers = headers , data = {"query" : query })
111+ response = requests .post (
112+ url ,
113+ headers = headers ,
114+ data = {"query" : query },
115+ timeout = 10 ,
116+ )
112117 data = response .json ()
113118
114119 if response .status_code == 200 :
@@ -136,7 +141,7 @@ def get_post(self, post_id):
136141 "User-Agent" : USER_AGENT ,
137142 }
138143
139- response = requests .get (url , headers = headers )
144+ response = requests .get (url , headers = headers , timeout = 10 )
140145
141146 if response .status_code == 200 :
142147 return {
@@ -167,7 +172,7 @@ def get_thread(self, thread_id, page=None):
167172 if page and page > 1 :
168173 headers ["page" ] = str (page )
169174
170- response = requests .get (url , headers = headers )
175+ response = requests .get (url , headers = headers , timeout = 10 )
171176
172177 if response .status_code != 200 :
173178 return response .json ()
@@ -277,7 +282,7 @@ def get_editorials(self, page=None, post_type=None, sort=None):
277282 "data" : {"posts" : [], "users" : []},
278283 }
279284
280- response = requests .get (url , headers = headers )
285+ response = requests .get (url , headers = headers , timeout = 10 )
281286 data = response .json ()
282287
283288 # Page out of range.
@@ -310,6 +315,7 @@ def create_post(self, thread_id, message):
310315 headers = headers ,
311316 data = data ,
312317 cookies = self ._cookies ,
318+ timeout = 10 ,
313319 )
314320
315321 # Has no auth token.
@@ -354,6 +360,7 @@ def edit_post(self, post_id, message):
354360 headers = headers ,
355361 data = data ,
356362 cookies = self ._cookies ,
363+ timeout = 10 ,
357364 )
358365
359366 # Has no auth token.
@@ -406,7 +413,13 @@ def create_thread(self, title, message, category_name, post_type=None):
406413 "title" : title ,
407414 "body" : message ,
408415 }
409- response = requests .post (url , headers = headers , data = data , cookies = self ._cookies )
416+ response = requests .post (
417+ url ,
418+ headers = headers ,
419+ data = data ,
420+ cookies = self ._cookies ,
421+ timeout = 10 ,
422+ )
410423
411424 # Validation errors. Happens when title or message is empty. Possibly in other cases too.
412425 if response .status_code == 400 :
0 commit comments