def get_stack_var(name, depth=0):
    '''This function may fiddle with the locals of the calling function,
    to make it the root function of the fiber. If called from a short-lived
    function be sure to use a bigger frame depth.
    Returns the fiber state or None.'''

    base_frame = _get_base_frame(depth)
    if not base_frame:
        # Frame not found
        raise RuntimeError("Base frame not found")

    # Lookup up the frame stack starting at the base frame for the fiber state
    level = 0
    frame = base_frame
    while frame:
        locals = frame.f_locals
        value = locals.get(name)
        if value is not None:
            if level > 0:
                # Copy a reference of the fiber state in the base frame
                base_frame.f_locals[name] = value
            return value
        if locals.get(SECTION_BOUNDARY_TAG):
            return None
        frame = frame.f_back
        level += 1
    return None
def get_stack_var ( name , depth = 0 ) : base_frame = _get_base_frame ( depth ) if not base_frame : raise RuntimeError ( "Base frame not found" ) level = 0 frame = base_frame while frame : locals = frame . f_locals value = locals . get ( name ) if value is not None : if level > 0 : base_frame . f_locals [ name ] = value return value if locals . get ( SECTION_BOUNDARY_TAG ) : return None frame = frame . f_back level += 1 return None
This function may fiddle with the locals of the calling function,
    to make it the root function of the fiber. If called from a short-lived
    function be sure to use a bigger frame depth.
    Returns the fiber state or None.