Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoepp committed Feb 15, 2015
1 parent 44547fc commit e58d575
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/advanced_usage_ts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Proxy usage

To use a HTTPS proxy at initialization of the :class:`TwitterSearch` class, an addition argument named ``proxy='some.proxy:888'`` can be used. Otherwise the authentication will fail if the client has no direct access to the Twitter API.

Avoid rate-limitation with callback method
------------------------------------------
Avoid rate-limitation using a callback method
----------------------------------------------

Sometimes there is the need to build in certain delays in order to avoid being `rate-limited <https://dev.twitter.com/rest/public/rate-limiting>`_ by Twitter. One way to add an artificial delay to your queries is to use the build-in module ``time`` of Python in combination with a callback method. The following example demonstrates how to use the ``callback`` argument of the ``TwitterSearch.search_tweets_iterable()`` method properly. In this particular case every 5th call to the Twitter API activates a delay of 60 seconds.

Expand Down Expand Up @@ -71,6 +71,10 @@ Sometimes there is the need to build in certain delays in order to avoid being `
Remember that the callback is called every time a query to the Twitter API is performed. It's in your responsibility to make sure that your code doesn't have any unwanted side-effects or throws unintended exceptions. Also, every closure submitted via the ``callback`` argument is called with a the current instance of :class:`TwitterSearch`. Performing a delay is just one way to use this callback pattern.


Avoid rate-limitation manually
------------------------------

As you might know there is a certain amount of `meta-data <#access-meta-data>`_ available when using *TwitterSearch*. Some users might want to rely only on the ``get_statistics()`` method of the :class:`TwitterSearch` to trigger, for example, an artificial delay. This function returns a tuple of two integers. The first integer represents the amount of queries sent to Twitter so far, while the second one is an automatically increasing counter of the so far received tweets during those queries. Thus, an example taking those two meta-information into account could look like:

.. code-block:: python
Expand Down

0 comments on commit e58d575

Please sign in to comment.