Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40971ac

Browse files
committed
fixing nasty bug caused by retrying counter
1 parent 712e238 commit 40971ac

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lib/request/connect.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ def getPage(**kwargs):
102102
response = kwargs.get('response', False)
103103
ignoreTimeout = kwargs.get('ignoreTimeout', kb.ignoreTimeout)
104104
refreshing = kwargs.get('refreshing', False)
105+
retrying = kwargs.get('retrying', False)
105106

106107
# flag to know if we are dealing with the same target host
107108
target = reduce(lambda x, y: x == y, map(lambda x: urlparse.urlparse(x).netloc.split(':')[0], [url, conf.url]))
108109

110+
if not retrying:
111+
# Reset the number of connection retries
112+
threadData.retriesCount = 0
113+
109114
# fix for known issue when urllib2 just skips the other part of provided
110115
# url splitted with space char while urlencoding it in the later phase
111116
url = url.replace(" ", "%20")
@@ -270,9 +275,6 @@ def getPage(**kwargs):
270275

271276
conf.redirectHandled = True
272277

273-
# Reset the number of connection retries
274-
threadData.retriesCount = 0
275-
276278
# Return response object
277279
if response:
278280
return conn, None
@@ -425,9 +427,10 @@ def getPage(**kwargs):
425427
time.sleep(1)
426428

427429
socket.setdefaulttimeout(conf.timeout)
430+
kwargs['retrying'] = True
428431
return Connect.__getPageProxy(**kwargs)
429432
elif kb.testMode:
430-
logger.warn(warnMsg)
433+
logger.critical(warnMsg)
431434
return None, None
432435
else:
433436
socket.setdefaulttimeout(conf.timeout)

0 commit comments

Comments
 (0)