Closed jasonwbarnett closed 1 week ago
It seemed like https://github.com/DonDebonair/slack-machine/pull/1115 is dead so I'm trying to resurrect since it's a fairly straight forward change that is needed for larger Slack deployments.
Great addition! I left one comment with a proposed alternative approach to reusing the retry logic. Aside from that, both ruff
and mypy
complain 😅
Great addition! I left one comment with a proposed alternative approach to reusing the retry logic. Aside from that, both
ruff
andmypy
complain 😅
Thanks for quick review. I'll take a loop on these items today/tomorrow.
@DonDebonair Ready for 👀
MyPy is not happy and I think the code can be simplified :) See my comment.
Apologies for the back-and-forth, I tend to be nitpicky about code readability.
MyPy is not happy and I think the code can be simplified :) See my comment.
Apologies for the back-and-forth, I tend to be nitpicky about code readability.
No problem. I am picky about readability as well.
Summary
This PR introduces asynchronous rate limit handling to improve Slack Machine’s resilience when interacting with the Slack API. By incorporating error management for
SlackApiError
and implementing a retry mechanism, this update aims to minimize disruptions during high-volume API requests and ensure the bot doesn't fail to start under rate-limiting conditions, such as when there are thousands of users and/or channels.Fixes https://github.com/DonDebonair/slack-machine/issues/975
Changes
SlackApiError
with specific checks for rate-limiting errors, allowing the bot to pause and retry when limits are hit.build_paginated_cache
, a method for managing paginated API responses, enabling smoother and more efficient data handling.Motivation
Slack’s API rate limits can cause disruptions in bot functionality, especially in high-demand environments. This PR adds rate limit handling to Slack Machine, providing a smoother, more resilient user experience.
Testing
All changes have been tested locally under various rate-limit scenarios to confirm proper error handling and retry logic.