METADATA 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Metadata-Version: 2.0
  2. Name: ratelim
  3. Version: 0.1.6
  4. Summary: Makes it easy to respect rate limits.
  5. Home-page: http://github.com/themiurgo/ratelim
  6. Author: Antonio Lima
  7. Author-email: anto87@gmail.com
  8. License: MIT
  9. Platform: UNKNOWN
  10. Requires-Dist: decorator
  11. Ratelim
  12. =======
  13. Ratelim is a simple Python library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.
  14. Features
  15. --------
  16. - Works in Py2 and Py3.
  17. - Greedy and patient rate limiting.
  18. - Preserves function signature.
  19. Installation
  20. ------------
  21. .. code-block:: bash
  22. $ pip install ratelim
  23. Usage
  24. -----
  25. Say you want to call a function at most for ``n_calls`` during a ``n_seconds`` time interval.
  26. .. code-block:: python
  27. # 10 times in 5 seconds
  28. @ratelim.greedy(10, 5)
  29. def hello():
  30. print("hello")
  31. The ``greedy`` rate limiter calls does not delay any function call until it's really necessary.
  32. In some scenarios, for example when crawling data from an API, you want to maximize the number
  33. of calls you make and you want to avoid sending them in short sequence. To this aim, we can
  34. use the ``patient`` rate limiter. It distributes calls evenly between each other.
  35. .. code-block:: python
  36. # 10 times in 5 seconds
  37. # Gets called at most every 0.5 seconds
  38. @ratelim.patient(10, 5)
  39. def hello():
  40. print("hello")
  41. LICENSE
  42. -------
  43. MIT.