def METHOD_NAME(func, reset):
    @functools.wraps(func)
    def wrapper(state, *args, **kwargs):
        notification_manager.init()
        notification_manager.register_listener(state)
        skip_sync = False
        try:
            while True:
                try:
                    if not skip_sync:
                        state.sync()
                    return func(state, *args, **kwargs)
                except HorovodInternalError:
                    state.restore()
                    skip_sync = False
                except HostsUpdatedInterrupt as e:
                    skip_sync = e.skip_sync
                reset()
                state.on_reset()
        finally:
            notification_manager.remove_listener(state)
    return wrapper