mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-17 21:01:00 +00:00
News timeout
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@59 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
67161585b3
commit
6e2797d2fd
2 changed files with 12 additions and 21 deletions
|
|
@ -168,16 +168,22 @@ class Configuration(UserDict.UserDict):
|
|||
|
||||
def connectNntp_NoThreads(self):
|
||||
if not self.data.has_key("nntp"):
|
||||
import nntplib
|
||||
self.data["nntp"] = nntplib.NNTP(self.data["nntpserver"])
|
||||
_do_connectNntp()
|
||||
|
||||
def connectNntp_Threads(self):
|
||||
if not self.data.has_key("nntp"):
|
||||
import nntplib
|
||||
self.dataLock.acquire()
|
||||
self.data["nntp"] = nntplib.NNTP(self.data["nntpserver"])
|
||||
_do_connectNntp()
|
||||
self.dataLock.release()
|
||||
|
||||
def _co_connectNntp():
|
||||
import nntplib
|
||||
try:
|
||||
self.data["nntp"] = nntplib.NNTP(self.data["nntpserver"])
|
||||
except:
|
||||
print sys.exc_info()[:2]
|
||||
raise
|
||||
|
||||
def hasMoreUrls_Threads(self):
|
||||
return not self.urls.empty()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import re,string,time,nntplib,sys
|
||||
import re,string,time,nntplib
|
||||
from HostCheckingUrlData import HostCheckingUrlData
|
||||
from UrlData import LinkCheckerException
|
||||
|
||||
|
|
@ -19,22 +19,7 @@ class NntpUrlData(HostCheckingUrlData):
|
|||
self.setWarning("No NNTP server specified, checked only syntax")
|
||||
config.connectNntp()
|
||||
nntp = config["nntp"]
|
||||
timeout = 1
|
||||
while timeout:
|
||||
try:
|
||||
resp,count,first,last,name = nntp.group(self.host)
|
||||
timeout = 0
|
||||
except nntplib.error_perm:
|
||||
type,value = sys.exc_info()[:2]
|
||||
print type,value
|
||||
if value[0]==505:
|
||||
# 505 too many connections per minute
|
||||
import random
|
||||
time.sleep(random.randint(30,60))
|
||||
# try again
|
||||
timeout = 1
|
||||
else:
|
||||
raise
|
||||
resp,count,first,last,name = nntp.group(self.host)
|
||||
self.setInfo("Group %s has %s articles, range %s to %s" % \
|
||||
(name, count, first, last))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue