Add semaphore support for limiting concurrent updates#1670
Merged
JrooTJunior merged 3 commits intodev-3.xfrom Apr 12, 2025
Merged
Add semaphore support for limiting concurrent updates#1670JrooTJunior merged 3 commits intodev-3.xfrom
JrooTJunior merged 3 commits intodev-3.xfrom
Conversation
Introduce a semaphore-based mechanism to control the number of concurrent tasks in polling mode when `handle_as_tasks=True`. Added the `tasks_concurrency_limit` parameter to `start_polling()` and `run_polling()`, preventing potential memory exhaustion during high update loads.
✔️ Changelog found.Thank you for adding a description of the changes |
Contributor
There was a problem hiding this comment.
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
Files not reviewed (1)
- CHANGES/1658.bugfix.rst: Language not supported
Comments suppressed due to low confidence (2)
tests/test_dispatcher/test_dispatcher.py:813
- The docstring refers to 'concurrent_updates_limit', but the parameter is named 'tasks_concurrency_limit'. Please update the docstring for consistency.
"""Test that semaphore is created only when handle_as_tasks=True and concurrent_updates_limit is not None"""
aiogram/dispatcher/dispatcher.py:367
- The comment references 'concurrent_updates_limit' which is inconsistent with the parameter name 'tasks_concurrency_limit'. Consider updating the comment to match the parameter name.
# Create a semaphore if concurrent_updates_limit is specified
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-3.x #1670 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 511 511
Lines 12536 12546 +10
=========================================
+ Hits 12536 12546 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
Olegt0rr
approved these changes
Apr 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce a semaphore-based mechanism to control the number of concurrent tasks in polling mode when
handle_as_tasks=True. Added thetasks_concurrency_limitparameter tostart_polling()andrun_polling(), preventing potential memory exhaustion during high update loads.Fixes #1658
Type of change
Checklist: