os / slacker

Full-featured Python interface for the Slack API
Apache License 2.0
1.6k stars 245 forks source link

adding Retry-After to the error if possible #40

Closed diwu1989 closed 9 years ago

diwu1989 commented 9 years ago

According to https://api.slack.com/docs/rate-limits

If you go over these limits when using our HTTP based APIs, including Incoming Webhooks,
Slack will start returning a HTTP 429 Too Many Requests error, a JSON object containing the
number of calls you have been making, and a Retry-After header containing the number of seconds
until you can retry.

Read the response header and if the Retry-After header has been set, parse and set it on the exception instance being raised.

terite commented 9 years ago

The previous assert or raise_for_status will prevent this code from running, since Too Many Requests should not be HTTP 200

os commented 9 years ago

Good catch! Thanks @terite @diwu1989