def METHOD_NAME(self) -> None:
    """Calculate and update the average transfer speed every second."""
    times_we_got_data = 0
    while not self.done and not self.cancel:
        if self.pause:
            time.sleep(self._update_loop_sleep_time / 10)
            continue
        bytes_transferred_this_second = sum(self._last_transferred_sizes)
        self._last_transferred_sizes.clear()
        previous_speed = self.average_speed
        consider_past_secs = min(times_we_got_data, self.speed_period) or 1
        self.average_speed = max(
            0,
            self.average_speed * (consider_past_secs - 1) / consider_past_secs
            + bytes_transferred_this_second / consider_past_secs,
        )
        if self.average_speed != previous_speed and self.on_speed_changed:
            self.on_speed_changed(self.average_speed)
        if bytes_transferred_this_second:
            times_we_got_data += 1
        time.sleep(self._update_loop_sleep_time)
    if self.done and not self.average_speed:
        # Transfer was fast enough to end before we had time to calculate
        self.average_speed = self.total_size