Skip to content

Commit

Permalink
adding rate-limit and request options usage to README (#238)
Browse files Browse the repository at this point in the history
* adding rate-limit and request options usage to README

* bump version

- need to release a new version due to Python 2 retire
  • Loading branch information
smaeda-ks committed Dec 5, 2019
1 parent d239bd8 commit aeb7484
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,50 @@ Command Line Helper
For more help please see our `Examples and Guides`_ or check the online
`Reference Documentation`_.

Rate-limit handling and request options
'''''''''''''''''''

.. code:: python
client = Client(
CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET,
options={
'handle_rate_limit': True,
'retry_max': 3,
'retry_delay': 5000,
'retry_on_status': [404, 500, 503],
'retry_on_timeouts': True,
'timeout': (1.0, 3.0)
})
.. list-table::

* - Parameter
- Default
- Description
* - ``handle_rate_limit``
- ``False`` (boolean)
- Set ``True`` will check rate-limit response header and sleep if the request reached the limit (429).
* - ``retry_max``
- ``0`` (int)
- The number of times you want to retry when response code is found in ``retry_on_status``.
* - ``retry_delay``
- ``1500`` (int)
- The number of **milliseconds** you want to sleep before retry.
* - ``retry_on_status``
- ``[500, 503]`` (list)
- The response codes you want to retry on. You can only set >= 400 status codes.
* - ``retry_on_timeouts``
- ``False`` (boolean)
- Set ``True`` will catch the timeout error and retry the request.
* - ``timeout``
- ``None``
- You can specify either a single value OR a tuple. If a single value is specified, the timeout value will be applied to both the ``connect`` and the ``read`` timeouts. See https://2.python-requests.org/en/master/user/advanced/#timeouts for more details of the usage.

Compatibility & Versioning
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion twitter_ads/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2015 Twitter, Inc.

VERSION = (6, 0, 2)
VERSION = (6, 1, 0)
API_VERSION = '6'

from twitter_ads.utils import get_version
Expand Down

0 comments on commit aeb7484

Please sign in to comment.