slackapi / python-slack-sdk

Slack Developer Kit for Python
https://slack.dev/python-slack-sdk/
MIT License
3.84k stars 838 forks source link

Add smart Rate Limiter #1101

Open seratch opened 3 years ago

seratch commented 3 years ago

Now that we have a built-in retry handler for rate limited errors in v3.9, retrying a request after getting rate-limited is much easier than before.

However, getting rate-limited results in a much longer execution time as the whole operation. As a solution for this pain point, we will add a built-in traffic control layer like we do in the Java SDK: https://slack.dev/java-slack-sdk/guides/web-api-basics#rate-limits

A few points to consider for implementing this feature:

Category (place an x in each of the [ ])

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

seratch commented 2 years ago

I've implemented a similar thing in the Discovery API SDK: https://github.com/slackapi/python-slack-discovery-sdk/blob/main/slack_discovery_sdk/rate_limit_support.py The ones for the APIs supported by this SDK (especially the Web APIs) would require a bit more complex logic, though.