def _get_runner(directives, stop_event):
    """Return a function that runs all the directives in the given list until
    the stop event is set.
    """
    def runner():
        for directive in directives:
            if not stop_event.is_set():
                directive.run()
            else:
                break
    return runner