summaryrefslogtreecommitdiff
path: root/mercurial/keepalive.py
diff options
context:
space:
mode:
Diffstat (limited to 'mercurial/keepalive.py')
-rw-r--r--mercurial/keepalive.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
index 13243ba..205a9e6 100644
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -9,8 +9,10 @@
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, see
-# <http://www.gnu.org/licenses/>.
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
# This file is part of urlgrabber, a high-level cross-protocol url-grabber
# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
@@ -136,7 +138,7 @@ class ConnectionManager(object):
def add(self, host, connection, ready):
self._lock.acquire()
try:
- if host not in self._hostmap:
+ if not host in self._hostmap:
self._hostmap[host] = []
self._hostmap[host].append(connection)
self._connmap[connection] = host
@@ -211,7 +213,7 @@ class KeepAliveHandler(object):
h.close()
def _request_closed(self, request, host, connection):
- """tells us that this request is now closed and that the
+ """tells us that this request is now closed and the the
connection is ready for another request"""
self._cm.set_ready(connection, 1)
@@ -290,7 +292,7 @@ class KeepAliveHandler(object):
# worked. We'll check the version below, too.
except (socket.error, httplib.HTTPException):
r = None
- except: # re-raises
+ except:
# adding this block just in case we've missed
# something we will still raise the exception, but
# lets try and close the connection and remove it
@@ -534,7 +536,7 @@ def safesend(self, str):
if self.auto_open:
self.connect()
else:
- raise httplib.NotConnected
+ raise httplib.NotConnected()
# send the data to the server. if we get a broken pipe, then close
# the socket. we want to reconnect when somebody tries to send again.
@@ -545,14 +547,13 @@ def safesend(self, str):
print "send:", repr(str)
try:
blocksize = 8192
- read = getattr(str, 'read', None)
- if read is not None:
+ if hasattr(str,'read') :
if self.debuglevel > 0:
print "sendIng a read()able"
- data = read(blocksize)
+ data = str.read(blocksize)
while data:
self.sock.sendall(data)
- data = read(blocksize)
+ data = str.read(blocksize)
else:
self.sock.sendall(str)
except socket.error, v:
@@ -758,7 +759,7 @@ if __name__ == '__main__':
try:
N = int(sys.argv[1])
url = sys.argv[2]
- except (IndexError, ValueError):
+ except:
print "%s <integer> <url>" % sys.argv[0]
else:
test(url, N)