def register(self, peer):
        """
        Registers a peer according to its description

        :param peer: A Peer description bean
        :raise KeyError:
        """
        assert isinstance(peer, beans.Peer)

        with self.__lock:
            # Check presence
            peer_id = peer.peer_id
            if peer_id in self.peers:
                raise KeyError("Already known peer: {0}".format(peer))

            # Store the description
            self.peers[peer_id] = peer

            # Store in the groups
            for name in peer.groups:
                self.groups.setdefault(name, set()).add(peer_id)
def register ( self , peer ) : assert isinstance ( peer , beans . Peer ) with self . __lock : peer_id = peer . peer_id if peer_id in self . peers : raise KeyError ( "Already known peer: {0}" . format ( peer ) ) self . peers [ peer_id ] = peer for name in peer . groups : self . groups . setdefault ( name , set ( ) ) . add ( peer_id )
Registers a peer according to its description

        :param peer: A Peer description bean
        :raise KeyError: