From ce3eb27e1f8ebe3686fdff7bd049076c7dc7d5b8 Mon Sep 17 00:00:00 2001 From: calvin Date: Sun, 29 Oct 2000 11:24:00 +0000 Subject: [PATCH] no timeoutsocket git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@181 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- README | 10 ---------- TODO | 4 +--- debian/changelog | 2 -- http11lib.py | 2 +- linkcheck/NntpUrlData.py | 2 +- linkchecker | 4 ++-- timeoutsocket.py | 11 +++++------ 7 files changed, 10 insertions(+), 25 deletions(-) diff --git a/README b/README index e14e1642..a1ac73d2 100644 --- a/README +++ b/README @@ -104,13 +104,3 @@ We call init() once to initialize the Logger. UrlData.check() calls newUrl() (through UrlData.logMe()) and after all checking we call endOfOutput(). Easy. New loggers are created with the Config.newLogger(name, fileoutput) function. - - -Nifty features you did not expect ---------------------------------- -o Included brain enhancer. Just read Python code to gain intelligence. -o Wash-O-matic. LinkChecker has a secret option which washes all your - dirty clothes in a matter of seconds. -o Y10K-Compatibility(tm) guaranteed. Trust me on that one. -o There is no spoon. Wake up already! - diff --git a/TODO b/TODO index 79e9d8e6..8eb1b90d 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ High priority -o DNS (and some URLs) seem to hang sometimes. This is not entirely true. - The SMTP connect has a very long timeout (>200 seconds). - But I can not use the signal module with threads. +o Use Python 2.0 features o I want to be able to supply a "break" command even when multiple threads are running. diff --git a/debian/changelog b/debian/changelog index d66e20d9..c43b7e42 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,6 @@ linkchecker (1.2.6) unstable; urgency=low * configuration changes: distutils are now required; because of that we have no more .tmpl files * fix db name in create.sql - * added timeoutsocket.py to supply a timeout for socket.connect() - calls * fix tag parsing when a quoted tag attribute value contains a > character diff --git a/http11lib.py b/http11lib.py index c06ab447..398ec7cc 100644 --- a/http11lib.py +++ b/http11lib.py @@ -195,7 +195,7 @@ class HTTPConnection: def connect(self): """Connect to the host and port specified in __init__.""" self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.connect(self.host, self.port) + self.sock.connect((self.host, self.port)) def close(self): """Close the connection to the HTTP server.""" diff --git a/linkcheck/NntpUrlData.py b/linkcheck/NntpUrlData.py index 09e36475..a23e735a 100644 --- a/linkcheck/NntpUrlData.py +++ b/linkcheck/NntpUrlData.py @@ -76,7 +76,7 @@ class NntpUrlData(UrlData): timeout = 0 except nntplib.error_perm: value = sys.exc_info()[1] - debug("NNTP: "+value+"\n") + debug("NNTP: %s\n" % value) if re.compile("^505").search(str(value)): import whrandom time.sleep(whrandom.randint(10,20)) diff --git a/linkchecker b/linkchecker index 2ed0df3c..8dbb7c9f 100755 --- a/linkchecker +++ b/linkchecker @@ -6,8 +6,8 @@ if sys.version[:5] < "1.5.2": raise SystemExit, "This program requires Python 1.5.2 or later." import getopt,re,string,os,urlparse # 90 seconds timeout for all connections -import timeoutsocket -timeoutsocket.setDefaultSocketTimeout(90) +#import timeoutsocket +#timeoutsocket.setDefaultSocketTimeout(90) import linkcheck, StringUtil from linkcheck import _ diff --git a/timeoutsocket.py b/timeoutsocket.py index 2669b06c..9e28ac5c 100644 --- a/timeoutsocket.py +++ b/timeoutsocket.py @@ -147,9 +147,9 @@ class TimeoutSocket: self._timeout = timeout # end set_timeout - def connect(self, addr, port=None, dumbhack=None): + def connect(self, addr, dumbhack=None): # In case we were called as connect(host, port) - if port != None: addr = (addr, port) + #if port != None: addr = (addr, port) # Shortcuts sock = self._sock @@ -221,10 +221,9 @@ class TimeoutSocket: def send(self, data, flags=0): sock = self._sock - timeout = self._timeout totallen = 0 while data: - r,w,e = select.select([],[sock], [], timeout) + r,w,e = select.select([],[sock], [], self._timeout) if not w: raise Timeout("Send timed out") sentlen = sock.send(data, flags) @@ -279,12 +278,12 @@ class TimeoutFile: break bufsize = self._bufsize if size > 0: - bufsize = min(bufsize, size - datalen ) + bufsize = min(bufsize, size - datalen) buf = self.recv(bufsize) if not buf: break data = data + buf - if size > 0 and datalen > size: + if datalen > size > 0: self._sock._inqueue = data[size:] data = data[:size] return data