+ # we disconnect from down to up
+ def disconnectAll(self):
+ # we should not disconnect from upstream if
+ # there are still elements depending on us.
+ assert len(self.downstream_elements) == 0, "there are still downstream elements left"
+
+ # Sources don't have a source themselves. don't do anything here.
+ if self.source is not None:
+ self.source.disconnectDownstream(self)
+
+ def disconnectDownstream(self, downstream):
+ self.downstream_elements.remove(downstream)
+ if self.master == downstream:
+ self.master = None
+
+ if len(self.downstream_elements) == 0:
+ self.disconnectAll()
+