class_docstr: This is a Rate Limiter implementation for synchronous functions
  (like geocoders with the default :class:`geopy.adapters.BaseSyncAdapter`).
  
  Examples::
  
      from geopy.extra.rate_limiter import RateLimiter
      from geopy.geocoders import Nominatim
  
      geolocator = Nominatim(user_agent="specify_your_app_name_here")
  
      search = ["moscow", "paris", "berlin", "tokyo", "beijing"]
      geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
      locations = [geocode(s) for s in search]
  
      search = [
          (55.47, 37.32), (48.85, 2.35), (52.51, 13.38),
          (34.69, 139.40), (39.90, 116.39)
      ]
      reverse = RateLimiter(geolocator.reverse, min_delay_seconds=1)
      locations = [reverse(s) for s in search]
  
  RateLimiter class is thread-safe. If geocoding service's responses
  are slower than `min_delay_seconds`, then you can benefit from
  parallelizing the work::
  
      import concurrent.futures
  
      geolocator = OpenMapQuest(api_key="...")
      geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1/20)
  
      with concurrent.futures.ThreadPoolExecutor() as e:
          locations = list(e.map(geocode, search))
  
  .. versionchanged:: 2.0
     Added thread-safety support.
docstr: :param callable func:
      A function which should be wrapped by the rate limiter.
  
  :param float min_delay_seconds:
      Minimum delay in seconds between the wrapped ``func`` calls.
      To convert :abbr:`RPS (Requests Per Second)` rate to
      ``min_delay_seconds`` you need to divide 1 by RPS. For example,
      if you need to keep the rate at 20 RPS, you can use
      ``min_delay_seconds=1/20``.
  
  :param int max_retries:
      Number of retries on exceptions. Only
      :class:`geopy.exc.GeocoderServiceError` exceptions are
      retried -- others are always re-raised. ``max_retries + 1``
      requests would be performed at max per query. Set
      ``max_retries=0`` to disable retries.
  
  :param float error_wait_seconds:
      Time to wait between retries after errors. Must be
      greater or equal to ``min_delay_seconds``.
  
  :param bool swallow_exceptions:
      Should an exception be swallowed after retries? If not,
      it will be re-raised. If yes, the ``return_value_on_exception``
      will be returned.
  
  :param return_value_on_exception:
      Value to return on failure when ``swallow_exceptions=True``.
docstr_tok: [":","param","callable","func",":","A","function","which","should","be","wrapped","by","the","rate","limiter",".",":","param","float","min_delay_seconds",":","Minimum","delay","in","seconds","between","the","wrapped","``","func","``","calls",".","To","convert",":","abbr",":","`","RPS","(","Requests","Per","Second",")","`","rate","to","``","min_delay_seconds","``","you","need","to","divide","1","by","RPS",".","For","example",",","if","you","need","to","keep","the","rate","at","20","RPS",",","you","can","use","``","min_delay_seconds=1\/20","``",".",":","param","int","max_retries",":","Number","of","retries","on","exceptions",".","Only",":","class",":","`","geopy.exc.GeocoderServiceError","`","exceptions","are","retried","--","others","are","always","re-raised",".","``","max_retries","+","1","``","requests","would","be","performed","at","max","per","query",".","Set","``","max_retries=0","``","to","disable","retries",".",":","param","float","error_wait_seconds",":","Time","to","wait","between","retries","after","errors",".","Must","be","greater","or","equal","to","``","min_delay_seconds","``",".",":","param","bool","swallow_exceptions",":","Should","an","exception","be","swallowed","after","retries","?","If","not",",","it","will","be","re-raised",".","If","yes",",","the","``","return_value_on_exception","``","will","be","returned",".",":","param","return_value_on_exception",":","Value","to","return","on","failure","when","``","swallow_exceptions=True","``","."]
code: def __init__(
      self,
      func,
      *,
      min_delay_seconds=0.0,
      max_retries=2,
      error_wait_seconds=5.0,
      swallow_exceptions=True,
      return_value_on_exception=None,
  ):
      """
      :param callable func:
          A function which should be wrapped by the rate limiter.
  
      :param float min_delay_seconds:
          Minimum delay in seconds between the wrapped ``func`` calls.
          To convert :abbr:`RPS (Requests Per Second)` rate to
          ``min_delay_seconds`` you need to divide 1 by RPS. For example,
          if you need to keep the rate at 20 RPS, you can use
          ``min_delay_seconds=1/20``.
  
      :param int max_retries:
          Number of retries on exceptions. Only
          :class:`geopy.exc.GeocoderServiceError` exceptions are
          retried -- others are always re-raised. ``max_retries + 1``
          requests would be performed at max per query. Set
          ``max_retries=0`` to disable retries.
  
      :param float error_wait_seconds:
          Time to wait between retries after errors. Must be
          greater or equal to ``min_delay_seconds``.
  
      :param bool swallow_exceptions:
          Should an exception be swallowed after retries? If not,
          it will be re-raised. If yes, the ``return_value_on_exception``
          will be returned.
  
      :param return_value_on_exception:
          Value to return on failure when ``swallow_exceptions=True``.
  
      """
      super().__init__(
          min_delay_seconds=min_delay_seconds,
          max_retries=max_retries,
          swallow_exceptions=swallow_exceptions,
          return_value_on_exception=return_value_on_exception,
      )
      self.func = func
      self.error_wait_seconds = error_wait_seconds
      assert error_wait_seconds >= min_delay_seconds
      assert max_retries >= 0
  
imports: import asyncio
  import inspect
  import threading
  from itertools import chain, count
  from time import sleep
  from timeit import default_timer
  from geopy.exc import GeocoderServiceError
  from geopy.util import logger
label_desc: Use image node_id 1 to create a new RateLimiter object from inherited base classes: BaseRateLimiter with example: obj = RateLimiter(func)