From aeb74842b80a397dfe01b3ee1a054bd6cdfc07e0 Mon Sep 17 00:00:00 2001 From: Shohei Maeda Date: Thu, 5 Dec 2019 17:51:26 +0900 Subject: [PATCH] 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 --- README.rst | 44 +++++++++++++++++++++++++++++++++++++++++ twitter_ads/__init__.py | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5980572..82f1072 100644 --- a/README.rst +++ b/README.rst @@ -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 -------------------------- diff --git a/twitter_ads/__init__.py b/twitter_ads/__init__.py index 6e9fd0a..00f34fa 100644 --- a/twitter_ads/__init__.py +++ b/twitter_ads/__init__.py @@ -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