@register_bounce_method('crossover')
def crossover_bounce(
    new_config,
    new_app_running,
    happy_new_tasks,
    old_app_live_happy_tasks,
    old_app_live_unhappy_tasks,
):

    if not new_app_running:
        return {
            "create_app": True,
            "tasks_to_drain": set(),
        }
    else:
        happy_count = len(happy_new_tasks)
        needed_count = max(new_config['instances'] - happy_count, 0)

        old_tasks = []
        for app, tasks in old_app_live_happy_tasks.items():
            for task in tasks:
                old_tasks.append(task)

        for app, tasks in old_app_live_unhappy_tasks.items():
            for task in tasks:
                old_tasks.append(task)
        return {
            "create_app": False,
            "tasks_to_drain": set(set(old_tasks[needed_count:])),
        }
Starts a new app if necessary; slowly kills old apps as instances of the new app become happy.
dataset/ETHPy150Open Yelp/paasta/paasta_tools/bounce_lib.py/crossover_bounce