Skip to content

Commit aeb7484

Browse files
authored
adding rate-limit and request options usage to README (#238)
* adding rate-limit and request options usage to README * bump version - need to release a new version due to Python 2 retire
1 parent d239bd8 commit aeb7484

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

README.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,50 @@ Command Line Helper
5656
For more help please see our `Examples and Guides`_ or check the online
5757
`Reference Documentation`_.
5858

59+
Rate-limit handling and request options
60+
'''''''''''''''''''
61+
62+
.. code:: python
63+
64+
client = Client(
65+
CONSUMER_KEY,
66+
CONSUMER_SECRET,
67+
ACCESS_TOKEN,
68+
ACCESS_TOKEN_SECRET,
69+
options={
70+
'handle_rate_limit': True,
71+
'retry_max': 3,
72+
'retry_delay': 5000,
73+
'retry_on_status': [404, 500, 503],
74+
'retry_on_timeouts': True,
75+
'timeout': (1.0, 3.0)
76+
})
77+
78+
79+
.. list-table::
80+
81+
* - Parameter
82+
- Default
83+
- Description
84+
* - ``handle_rate_limit``
85+
- ``False`` (boolean)
86+
- Set ``True`` will check rate-limit response header and sleep if the request reached the limit (429).
87+
* - ``retry_max``
88+
- ``0`` (int)
89+
- The number of times you want to retry when response code is found in ``retry_on_status``.
90+
* - ``retry_delay``
91+
- ``1500`` (int)
92+
- The number of **milliseconds** you want to sleep before retry.
93+
* - ``retry_on_status``
94+
- ``[500, 503]`` (list)
95+
- The response codes you want to retry on. You can only set >= 400 status codes.
96+
* - ``retry_on_timeouts``
97+
- ``False`` (boolean)
98+
- Set ``True`` will catch the timeout error and retry the request.
99+
* - ``timeout``
100+
- ``None``
101+
- 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.
102+
59103
Compatibility & Versioning
60104
--------------------------
61105

twitter_ads/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (C) 2015 Twitter, Inc.
22

3-
VERSION = (6, 0, 2)
3+
VERSION = (6, 1, 0)
44
API_VERSION = '6'
55

66
from twitter_ads.utils import get_version

0 commit comments

Comments
 (0)