Commit f9421da9 authored by Anael Beutot's avatar Anael Beutot Committed by Antoine Millet
Browse files

Fix on_disconnect callback handling.

When given a non RPC handler callback, it didn't work.
parent a822db64
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ class RpcProtocol(Protocol):
    :param connection: the connection serving this :class:`RpcProtocol`
    :param label: the label of this :class:`RpcProtocol` instance
    :param handler: command handler to bind by default
    :param on_disconnect: callback called when client disconnect
    :param on_disconnect: callback called when client disconnect, could be the
        name of an RPC handler or a callable
    :param timeout: global command timeout
    '''

@@ -283,8 +284,11 @@ class RpcProtocol(Protocol):
            self._handle_response({'id': cid, 'return': None, 'error': err})

        # Execute on_disconnect callback:
        if self._on_disconnect is None:
            return

        callback = None
        if self._on_disconnect is not None and not callable(self._on_disconnect):
        if not callable(self._on_disconnect):
            if self._handler is not None:
                try:
                    callback = self._handler[self._on_disconnect]
@@ -296,6 +300,8 @@ class RpcProtocol(Protocol):
                self.logger.warn('Shutdown callback specified but no handler '
                                 'binded on rpc, ignoring')
                callback = None
        else:
            callback = self._on_disconnect

        if callback is not None:
            try: