original_docstring: Update/create a :class:`Ratelimiter` attribute on ``self`` using a
          threshold string and attribute name.
  
          The :class:`Ratelimiter` is created from the provided threshold string.
          ``self`` is updated using the given ``attribute_name``. If the
          ratelimiter hasn't changed, then the old one will be kept.
  
          If the threshold string contains invalid syntax or is ``None``,
          the ratelimiter attribute becomes disabled.
          
docstring: 
  
  The :class:`Ratelimiter` is created from the provided threshold string.
  
  If the threshold string contains invalid syntax or is ``None``,
  the ratelimiter attribute becomes disabled.
docstring_tokens: The : class : ` Ratelimiter ` is created from the provided threshold string . If the threshold string contains invalid syntax or is ` ` None ` ` the ratelimiter attribute becomes disabled .
code: def _update_ratelimiter(
          self,
          threshold: T.Optional[str],
          attribute_name: str,
          *,
          after_update: T.Callable[[Ratelimiter, Ratelimiter], None] = None,
      ):
          """Update/create a :class:`Ratelimiter` attribute on ``self`` using a
          threshold string and attribute name.
  
          The :class:`Ratelimiter` is created from the provided threshold string.
          ``self`` is updated using the given ``attribute_name``. If the
          ratelimiter hasn't changed, then the old one will be kept.
  
          If the threshold string contains invalid syntax or is ``None``,
          the ratelimiter attribute becomes disabled.
          """
  
          try:
              if threshold is None:
                  raise TypeError
  
              old_ratelimiter = getattr(self, attribute_name)
  
              threshold = Threshold.from_string(threshold)
              new_ratelimiter = Ratelimiter(threshold.rate, threshold.per)
  
              if old_ratelimiter != new_ratelimiter:
                  setattr(self, attribute_name, new_ratelimiter)
                  self.log.debug(
                      "_update_ratelimiter: replacing stale ratelimiter %s",
                      attribute_name,
                  )
  
                  if after_update:
                      after_update(old_ratelimiter, new_ratelimiter)
              else:
                  self.log.debug(
                      "_update_ratelimiter: not stale, using old %s", attribute_name
                  )
          except TypeError:
              self.log.debug("_update_ratelimiter: invalid %s, disabling", attribute_name)
              setattr(self, attribute_name, None)
code_tokens: def _update_ratelimiter ( self , threshold : T . Optional [ str ] , attribute_name : str , * , after_update : T . Callable [ [ Ratelimiter , Ratelimiter ] , None ] = None , ) : try : if threshold is None : raise TypeError old_ratelimiter = getattr ( self , attribute_name ) threshold = Threshold . from_string ( threshold ) new_ratelimiter = Ratelimiter ( threshold . rate , threshold . per ) if old_ratelimiter != new_ratelimiter : setattr ( self , attribute_name , new_ratelimiter ) self . log . debug ( "_update_ratelimiter: replacing stale ratelimiter %s" , attribute_name , ) if after_update : after_update ( old_ratelimiter , new_ratelimiter ) else : self . log . debug ( "_update_ratelimiter: not stale, using old %s" , attribute_name ) except TypeError : self . log . debug ( "_update_ratelimiter: invalid %s, disabling" , attribute_name ) setattr ( self , attribute_name , None )
short_docstring: Update/create a :class:`Ratelimiter` attribute on ``self`` using a
  threshold string and attribute name.
short_docstring_tokens: Update / create a : class : ` Ratelimiter ` attribute on ` ` self ` ` using a threshold string and attribute name .
comment: """Update/create a :class:`Ratelimiter` attribute on ``self`` using a
          threshold string and attribute name.
  
          The :class:`Ratelimiter` is created from the provided threshold string.
          ``self`` is updated using the given ``attribute_name``. If the
          ratelimiter hasn't changed, then the old one will be kept.
  
          If the threshold string contains invalid syntax or is ``None``,
          the ratelimiter attribute becomes disabled.
          """