From 0f82b6f461b4a9a014bb4b4fa08d9fac1ed1a4e7 Mon Sep 17 00:00:00 2001 From: calvin Date: Sun, 5 May 2002 12:07:28 +0000 Subject: [PATCH] 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 --- linkcheck/NntpUrlData.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/linkcheck/NntpUrlData.py b/linkcheck/NntpUrlData.py index 762bc8f6..81a4b3d1 100644 --- a/linkcheck/NntpUrlData.py +++ b/linkcheck/NntpUrlData.py @@ -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):