changeset 4132:0d94e4a3ddb4

Close keepalive connections to fix server traceback
author Andrei Vermel <avermel@mail.ru>
date Mon, 19 Feb 2007 12:38:58 +0300
parents 1ca664c964e0
children a9ee6c53af8d
files mercurial/httprepo.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httprepo.py	Tue Feb 20 22:20:16 2007 +0100
+++ b/mercurial/httprepo.py	Mon Feb 19 12:38:58 2007 +0300
@@ -127,6 +127,7 @@
     def __init__(self, ui, path):
         self.path = path
         self.caps = None
+        self.handler = None
         scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
         if query or frag:
             raise util.Abort(_('unsupported URL component: "%s"') %
@@ -141,7 +142,8 @@
 
         proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
         # XXX proxyauthinfo = None
-        handlers = [httphandler()]
+        self.handler = httphandler()
+        handlers = [self.handler]
 
         if proxyurl:
             # proxy can be proper url or host[:port]
@@ -199,6 +201,11 @@
         # 1.0 here is the _protocol_ version
         opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
         urllib2.install_opener(opener)
+    
+    def __del__(self):
+        if self.handler:
+            self.handler.close_all()
+            self.handler = None
 
     def url(self):
         return self.path