def get_seed_users(tracks): seed_users = set() tmp = [] for i, t in enumerate(tracks, start=1): tmp.append(t["url"]) if len(tmp) == 10 or i == len(tracks): new_seeds = gevent_do(get_listening_now_users, tmp) for group in new_seeds: seed_users.update(set(group)) tmp = [] return seed_users