korbit-ai[bot] commented on code in PR #35622:
URL: https://github.com/apache/superset/pull/35622#discussion_r2426974025
##########
superset/utils/slack.py:
##########
@@ -73,19 +77,58 @@ def get_channels() -> list[SlackChannelSchema]:
channels: list[SlackChannelSchema] = []
extra_params = {"types": ",".join(SlackChannelTypes)}
cursor = None
+ page_count = 0
+ request_delay = app.config.get("SLACK_API_REQUEST_DELAY", 0.5)
+
+ logger.info(
+ "Starting Slack channels fetch with request delay of %.1fs",
+ request_delay,
+ )
+
+ try:
+ while True:
+ page_count += 1
+
+ # Add delay between requests to avoid rate limiting (skip first)
+ if page_count > 1:
+ logger.debug(
+ "Throttling: sleeping %.1fs before fetching page %d",
+ request_delay,
+ page_count,
+ )
+ time.sleep(request_delay)
Review Comment:
### Blocking sleep reduces concurrency <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Using synchronous sleep in a web application context blocks the entire
thread during API rate limiting delays.
###### Why this matters
This blocking sleep prevents the thread from handling other requests or
tasks, reducing overall application throughput and responsiveness, especially
problematic in web servers with limited thread pools.
###### Suggested change ∙ *Feature Preview*
Consider using asynchronous sleep with `asyncio.sleep()` if the function can
be made async, or implement a non-blocking rate limiting approach using a token
bucket or similar algorithm that doesn't require thread blocking.
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3a5b821f-b6dc-428d-979c-8e737fb3feed/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3a5b821f-b6dc-428d-979c-8e737fb3feed?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3a5b821f-b6dc-428d-979c-8e737fb3feed?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3a5b821f-b6dc-428d-979c-8e737fb3feed?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3a5b821f-b6dc-428d-979c-8e737fb3feed)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:eed741a2-d4ef-4a2c-80f1-694fd2841d8a -->
[](eed741a2-d4ef-4a2c-80f1-694fd2841d8a)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]