def _readable_duration(duration):
    """Convert a duration in seconds to a human-readable duration.

    Parameters
    ----------
    duration : int
        A duration in seconds.

    Returns
    -------
    str
        A human-readable duration.

    """
    rounded_duration = round(duration)

    if rounded_duration < 60:
        duration_string = "{}s".format(rounded_duration)
    elif rounded_duration < 60 * 60:
        minutes, seconds = divmod(rounded_duration, 60)
        duration_string = "{}m {:02d}s".format(minutes, seconds)
    else:
        total_minutes, seconds = divmod(rounded_duration, 60)
        hours, minutes = divmod(total_minutes, 60)
        duration_string = (
            "{:,}h {:02d}m {:02d}s".format(hours, minutes, seconds)
        )

    return duration_string