def coroutine_frames(all_frames):
    """Extract coroutine boilerplate frames from a frame list

    for better stack/traceback printing of coroutines
    """
    useful_frames = []
    for frame in all_frames:
        if frame[0] == '<string>' and frame[2] == 'raise_exc_info':
            continue
        elif frame[0].endswith('tornado/gen.py') and frame[2] in {'run',
            'wrapper', '__init__'}:
            continue
        elif frame[0].endswith('tornado/concurrent.py') and frame[2
            ] == 'result':
            continue
        useful_frames.append(frame)
    return useful_frames
