human
Complete the below
def _async_wait_until_running(reactor, instance):

    ''''Wait until a instance is running.
    :param reactor: The reactor.
    :param boto.ec2.instance.Instance instance: The instance to wait for.
    :return: Deferred that fires when the instance has become running
    or failed to run (within a predefined period of time).'
    '''

Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.
    action = start_action(action_type=u'flocker:provision:aws:wait_until_running', instance_id=instance.id)
    def check_final_state(ignored):
        if (instance.state != u'running'):
            raise FailedToRun(instance.state_reason)
        action.add_success_fields(instance_state=instance.state, instance_state_reason=instance.state_reason)
        return instance
    def finished_booting():
        d = maybeDeferred(_node_is_booting, instance)
        d.addCallback((lambda x: (not x)))
        return d
    with action.context():
        d = loop_until(reactor, finished_booting, repeat(5, INSTANCE_TIMEOUT))
        d = DeferredContext(d)
        d.addCallback(check_final_state)
        d.addActionFinish()
        return d.result