[docs]classCapacityUpdatingBucket(TokenBasedBucket):"""Mixin for buckets which token capacity can be updated."""
[docs]defupdate_capacity(self,new_capacity:float)->None:"""Update the bucket's token capacity. Changes take effect instantly, and the amount of remaining tokens is updated accordingly. Args: new_capacity: The new token capacity of the bucket. """validate_capacity(new_capacity)self._tokens+=new_capacity-self._capacityself._capacity=new_capacity