[Buildbot-commits] buildbot/buildbot/status builder.py,1.72,1.73

Brian Warner warner at users.sourceforge.net
Sun Nov 27 00:46:15 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3585/buildbot/status

Modified Files:
	builder.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-444
Creator:  Brian Warner <warner at lothar.com>

fix StatusReceiver unsubscribe bug

	* buildbot/status/builder.py (BuildStepStatus.unsubscribe): make
	sure that unsubscribe works even if we never sent an ETA update.
	Also, don't explode on duplicate unsubscribe.
	(BuildStepStatus.addLog): make the convenience "return self"-added
	watcher automatically unsubscribe when the Step finishes.
	(BuildStatus.unsubscribe): same handle-duplicate-unsubscribe
	(BuildStatus.stepStarted): same auto-unsubscribe
	(BuilderStatus.buildStarted): same auto-unsubscribe

	* buildbot/interfaces.py (IStatusReceiver.buildStarted): document
	auto-unsubscribe
	(IStatusReceiver.stepStarted): same
	(IStatusReceiver.logStarted): same

	* buildbot/test/test_run.py (Status): move the Status test..
	* buildbot/test/test_status.py (Subscription): .. to here


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- builder.py	5 Nov 2005 22:53:00 -0000	1.72
+++ builder.py	27 Nov 2005 00:46:13 -0000	1.73
@@ -802,9 +802,11 @@
                                                        updateInterval)
 
     def unsubscribe(self, receiver):
-        self.watchers.remove(receiver)
-        if self.updates[receiver] is not None:
-            self.updates[receiver].cancel()
+        if receiver in self.watchers:
+            self.watchers.remove(receiver)
+        if receiver in self.updates:
+            if self.updates[receiver] is not None:
+                self.updates[receiver].cancel()
             del self.updates[receiver]
 
 
@@ -830,6 +832,8 @@
             receiver = w.logStarted(self.build, self, log)
             if receiver:
                 log.subscribe(receiver, True)
+                d = log.waitUntilFinished()
+                d.addCallback(lambda log: log.unsubscribe(receiver))
         d = log.waitUntilFinished()
         d.addCallback(self.logFinished)
         return log
@@ -1060,9 +1064,11 @@
                                                        updateInterval)
 
     def unsubscribe(self, receiver):
-        self.watchers.remove(receiver)
-        if self.updates[receiver] is not None:
-            self.updates[receiver].cancel()
+        if receiver in self.watchers:
+            self.watchers.remove(receiver)
+        if receiver in self.updates:
+            if self.updates[receiver] is not None:
+                self.updates[receiver].cancel()
             del self.updates[receiver]
 
     # methods for the base.Build to invoke
@@ -1138,6 +1144,9 @@
                     step.subscribe(receiver[0], receiver[1])
                 else:
                     step.subscribe(receiver)
+                d = step.waitUntilFinished()
+                d.addCallback(lambda step: step.unsubscribe(receiver))
+
         step.waitUntilFinished().addCallback(self._stepFinished)
 
     def _stepFinished(self, step):
@@ -1586,6 +1595,9 @@
                     s.subscribe(receiver[0], receiver[1])
                 else:
                     s.subscribe(receiver)
+                d = s.waitUntilFinished()
+                d.addCallback(lambda s: s.unsubscribe(receiver))
+
 
     def _buildFinished(self, s):
         assert s in self.currentBuilds





More information about the Commits mailing list