'Waits for any previous key lookups for the given servers to finish.
Args:
server_names (list): list of server_names we want to lookup
server_to_deferred (dict): server_name to deferred which gets
resolved once we\'ve finished looking up keys for that server'

@defer.inlineCallbacks
def wait_for_previous_lookups(self, server_names, server_to_deferred):

    while True:
        wait_on = [self.key_downloads[server_name] for server_name in server_names if (server_name in self.key_downloads)]
        if wait_on:
            with PreserveLoggingContext():
                (yield defer.DeferredList(wait_on))
        else:
            break
    for (server_name, deferred) in server_to_deferred.items():
        d = ObservableDeferred(preserve_context_over_deferred(deferred))
        self.key_downloads[server_name] = d
        def rm(r, server_name):
            self.key_downloads.pop(server_name, None)
            return r
        d.addBoth(rm, server_name)
