

def _coordinateCallback2(self, discovered):
    existing_peers = set(self.peers.keys())
    discovered_peers = set(discovered.keys())
    new_peers = (discovered_peers - existing_peers)
    old_peers = (existing_peers - discovered_peers)
    for uuid in old_peers:
        LOGGER.debug(('Removing peer %s' % uuid))
        if (uuid in self.peers):
            del self.peers[uuid]
    deferreds = []
    for uuid in new_peers:
        if (uuid == self.uuid):
            self.peers[uuid] = {
                'uri': ('http://127.0.0.1:%s' % self.port),
                'local_ip': '127.0.0.1',
                'port': self.port,
                'active': True,
            }
        else:
            deferreds.append(self.verifyPeer(uuid, discovered[uuid]))
    if (len(new_peers) > 0):
        if (len(deferreds) > 0):
            d = DeferredList(deferreds, consumeErrors=True)
            d.addCallback(self._coordinateCallback3)
            return d
        else:
            self._coordinateCallback3(None)
    elif (len(old_peers) > 0):
        self._coordinateCallback3(None)
    else:
        pass

dataset/ETHPy150Open wehriam/awspider/awspider/servers/execution.py ExecutionServer._coordinateCallback2/original