Skip to content

Commit 3fcba67

Browse files
committed
Handling rare ChunkedEncodingError #6 caused by broken server connection
1 parent a946e7c commit 3fcba67

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

project/http/requests/proxy/requestProxy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from project.http.requests.useragent.userAgent import UserAgentManager
1010
import requests
1111
from requests.exceptions import ConnectionError
12+
from requests.exceptions import ChunkedEncodingError
1213
import random
1314
import time
1415
from requests.exceptions import ReadTimeout
@@ -77,6 +78,13 @@ def generate_proxied_request(self, url, params={}, req_timeout=30):
7778
pass
7879
print "Read timed out - Removed Straggling proxy: {0} PL Size = {1}".format(rand_proxy,
7980
len(self.proxy_list))
81+
except ChunkedEncodingError:
82+
try:
83+
self.proxy_list.remove(rand_proxy)
84+
except ValueError:
85+
pass
86+
print "Wrong server chunked encoding - Removed Straggling proxy: {0} PL Size = {1}".format(rand_proxy,
87+
len(self.proxy_list))
8088

8189

8290
if __name__ == '__main__':

0 commit comments

Comments
 (0)