mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-01 13:40:25 +00:00
catch 504 and 505 too busy errors, but dont try endlessly
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@416 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
d6056d9b3e
commit
0f82b6f461
1 changed files with 10 additions and 6 deletions
|
|
@ -66,20 +66,24 @@ class NntpUrlData (UrlData):
|
|||
self.setWarning(linkcheck._("No newsgroup specified in NNTP URL"))
|
||||
|
||||
def _connectNntp (self, nntpserver):
|
||||
"""This is done only once per checking task."""
|
||||
timeout = 1
|
||||
while timeout:
|
||||
"""This is done only once per checking task. Also, the newly
|
||||
introduced error codes 504 and 505 (both inclining "Too busy, retry
|
||||
later", are caught."""
|
||||
tries = 0
|
||||
nntp = None
|
||||
while tries < 5:
|
||||
tries += 1
|
||||
try:
|
||||
nntp=nntplib.NNTP(nntpserver)
|
||||
timeout = 0
|
||||
except nntplib.error_perm:
|
||||
value = sys.exc_info()[1]
|
||||
debug(BRING_IT_ON, "NNTP:", value)
|
||||
if re.compile("^505").search(str(value)):
|
||||
if re.compile("^50[45]").search(str(value)):
|
||||
import whrandom
|
||||
time.sleep(whrandom.randint(10,20))
|
||||
else:
|
||||
raise
|
||||
if nttp is None:
|
||||
raise linkcheck.error(_("NTTP server too busy; tried more than %d times")%tries)
|
||||
return nntp
|
||||
|
||||
def getCacheKey (self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue