def METHOD_NAME(tmgr, wait_queue_size):
    """
    this callback is called when the size of the task managers wait_queue
    changes.
    """
    print("[Callback]: TaskManager  '%s' wait_queue_size changed to %s."
        % (tmgr.uid, wait_queue_size))
    pilots = tmgr.get_pilots ()
    for pilot in pilots:
        print("pilot %s: %s" % (pilot.uid, pilot.state))
    if wait_queue_size == 0:
        for pilot in pilots:
            if pilot.state in [rp.PENDING_LAUNCH,
                                rp.LAUNCHING     ,
                                rp.PENDING_ACTIVE]:
                print("cancel pilot %s" % pilot.uid)
                tmgr.remove_pilot (pilot.uid)
                pilot.cancel ()