Esempio n. 1
0
 def on_circuit_built(self, callback):
     """
     :param callback: will be called (with 'circuit' instance) when a
         CIRC BUILT event happens
     """
     listener = CircuitListenerMixin()
     listener.circuit_built = callback
     self.add_circuit_listener(listener)
     return callback  # so we can be used as a listener
Esempio n. 2
0
 def on_circuit_failed(self, callback):
     """
     :param callback: will be called (with 'circuit' instance, and
         arbitrary kwargs) when a CIRC FAILED event happens
     """
     listener = CircuitListenerMixin()
     listener.circuit_failed = callback
     self.add_circuit_listener(listener)
     return callback  # so we can be used as a listener
Esempio n. 3
0
 def on_circuit_extend(self, callback):
     """
     :param callback: will be called (with 'circuit' and 'router'
         instances) when a CIRC EXTENDED event happens
     """
     listener = CircuitListenerMixin()
     listener.circuit_extend = callback
     self.add_circuit_listener(listener)
     return callback  # so we can be used as a listener
Esempio n. 4
0
    def test_listener_mixin(self):
        listener = CircuitListenerMixin()
        from zope.interface.verify import verifyObject
        self.assertTrue(verifyObject(ICircuitListener, listener))

        # call all the methods with None for each arg. This is mostly
        # just to gratuitously increase test coverage, but also
        # serves to ensure these methods don't just blow up
        for (methodname, desc) in ICircuitListener.namesAndDescriptions():
            method = getattr(listener, methodname)
            args = [None] * len(desc.positional)
            method(*args)