You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,50 @@ Command Line Helper
56
56
For more help please see our `Examples and Guides`_ or check the online
57
57
`Reference Documentation`_.
58
58
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.
0 commit comments