Avoid 'Rate limit exceeded' error on 'ls' command
authorLertsenem <lertsenem@lertsenem.com>
Sun, 11 Dec 2016 08:54:52 +0000 (09:54 +0100)
committerLertsenem <lertsenem@lertsenem.com>
Sun, 11 Dec 2016 08:54:52 +0000 (09:54 +0100)
commit787643bddacce47de1c0faafeaf1fa4c2e67b4f9
tree772cd668e4e54b7a402f5e421d7d9b12c309cfd7
parent7ce368df9167dc64f2bf3f0e29a287b4c922b637
Avoid 'Rate limit exceeded' error on 'ls' command

When listing friends or followers, the Twitter API sends them back to
you by batches of 20 users. If there are more, you then have to make
another request.

With more than 300 friends (or followers), this leads you to make more
than 15 calls. Unfortunately, the rate limit for this call is set at 15
calls per 15 mn.

This patch makes two modifications.

First, the users are printed out as they are received, and not once they
are all received.
Second, once you made 15 API requests, the program will wait for 16mn
before pursuing, in order to avoid the 'Rate limit exceeded' error.

This is not ideal (the stream is effectiveley in pause for 16mn...), but
still better that the old way, when, with 400 friends, all I could get
from 'ls fr' was 'Rate limit exceeded'. :)
rainbowstream/rainbow.py