[Buildbot-commits] buildbot/buildbot/status/web base.py, 1.13, 1.14 baseweb.py, 1.24, 1.25
Brian Warner
warner at users.sourceforge.net
Sun Sep 30 01:53:24 UTC 2007
Update of /cvsroot/buildbot/buildbot/buildbot/status/web
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12764/buildbot/status/web
Modified Files:
base.py baseweb.py
Log Message:
[project @ web: track HTTPChannels, so we can kill them at reconfig time. Closes #102]
Original author: warner at lothar.com
Date: 2007-09-30 01:52:54+00:00
Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/base.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- base.py 28 Sep 2007 09:33:31 -0000 1.13
+++ base.py 30 Sep 2007 01:53:22 -0000 1.14
@@ -174,6 +174,14 @@
return resource.Resource.getChild(self, path, request)
def render(self, request):
+ # tell the WebStatus about the HTTPChannel that got opened, so they
+ # can close it if we get reconfigured and the WebStatus goes away.
+ # They keep a weakref to this, since chances are good that it will be
+ # closed by the browser or by us before we get reconfigured. See
+ # ticket #102 for details.
+ if hasattr(request, "channel"):
+ # web.distrib.Request has no .channel
+ request.site.buildbot_service.registerChannel(request.channel)
# Our pages no longer require that their URL end in a slash. Instead,
# they all use request.childLink() or some equivalent which takes the
Index: baseweb.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/baseweb.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- baseweb.py 30 Sep 2007 01:04:12 -0000 1.24
+++ baseweb.py 30 Sep 2007 01:53:22 -0000 1.25
@@ -1,5 +1,5 @@
-import os, sys, time, urllib
+import os, sys, time, urllib, weakref
from itertools import count
from zope.interface import implements
@@ -341,7 +341,10 @@
"""
# we are not a ComparableMixin, and therefore the webserver will be
- # rebuilt every time we reconfig.
+ # rebuilt every time we reconfig. This is because WebStatus.putChild()
+ # makes it too difficult to tell whether two instances are the same or
+ # not (we'd have to do a recursive traversal of all children to discover
+ # all the changes).
def __init__(self, http_port=None, distrib_port=None, allowForce=False):
"""Run a web server that provides Buildbot status.
@@ -409,14 +412,9 @@
self.footer = FOOTER
self.template_values = {}
- # TODO: browsers will cache connections, and if we've recently
- # reloaded the config file, a browser might still be talking to the
- # previous Site, which will work for some things, but will break when
- # they try to reach through our .parent attribute (usually via
- # HtmlResource.getStatus(), which does
- # request.site.buildbot_service.parent). I don't know of a good way
- # to deal with this.. maybe the Site has some list of current
- # connections which we can crawl through and terminate?
+ # keep track of cached connections so we can break them when we shut
+ # down. See ticket #102 for more details.
+ self.channels = weakref.WeakKeyDictionary()
if self.http_port is not None:
s = strports.service(self.http_port, self.site)
@@ -470,6 +468,19 @@
"""This behaves a lot like root.putChild() . """
self.childrenToBeAdded[name] = child_resource
+ def registerChannel(self, channel):
+ self.channels[channel] = 1 # weakrefs
+
+ def stopService(self):
+ for channel in self.channels:
+ try:
+ channel.transport.loseConnection()
+ except:
+ log.msg("WebStatus.stopService: error while disconnecting"
+ " leftover clients")
+ log.err()
+ return service.MultiService.stopService(self)
+
def getStatus(self):
return self.parent.getStatus()
def getControl(self):
More information about the Commits
mailing list