Beispiel #1
0
    def disconnect(self, handler, weak=True):
        """
        Disconnects a specified handler.

        It is not necessary to disconnect object when it is deleted.
        Underlying PyDispatcher will take care of connections to deleted
        objects.

        >>> signal1 = Signal('signal1')
        >>> import sys
        >>> signal1.connect(sys.stdout.write)
        >>> signal1.disconnect(sys.stdout.write)

        The weak parameter of must have the same value as for connection.
        If you not specified the parameter when connecting,
        you don't have to specify it when disconnecting.

        Disconnecting the not-connected handler will result in error.

        >>> signal1.disconnect(sys.stdout.flush)  #doctest: +ELLIPSIS
        Traceback (most recent call last):
        DispatcherKeyError: 'No receivers found for signal ...'

        Disconnecting the non-exiting or unknown handler will result in error.

        >>> signal1.disconnect(some_function)
        Traceback (most recent call last):
        NameError: name 'some_function' is not defined
        >>> signal1.emit()
        """
        dispatcher.disconnect(receiver=handler, signal=self, weak=weak)
Beispiel #2
0
    def disconnect(self, handler, weak=True):
        """
        Disconnects a specified handler.

        It is not necessary to disconnect object when it is deleted.
        Underlying PyDispatcher will take care of connections to deleted
        objects.

        >>> signal1 = Signal('signal1')
        >>> import sys
        >>> signal1.connect(sys.stdout.write)
        >>> signal1.disconnect(sys.stdout.write)

        The weak parameter of must have the same value as for connection.
        If you not specified the parameter when connecting,
        you don't have to specify it when disconnecting.

        Disconnecting the not-connected handler will result in error.

        >>> signal1.disconnect(sys.stdout.flush)  #doctest: +ELLIPSIS
        Traceback (most recent call last):
        DispatcherKeyError: 'No receivers found for signal <__main__.Signal object at 0x...> from sender _Any'

        Disconnecting the non-exiting or unknown handler will result in error.

        >>> signal1.disconnect(some_function)
        Traceback (most recent call last):
        NameError: name 'some_function' is not defined
        >>> signal1.emit()
        """
        dispatcher.disconnect(receiver=handler, signal=self, weak=weak)