-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add backpressure mechanism to limit the number of concurrent outgoing calls #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. 👍 Please have a look at my comments in the review. Let me know if anything is unclear, or, if you have other suggestions. :)
I'd also like a comment somewhere along these lines: # TODO: Simplify the logic that surrounds `self._outgoing_calls_sem` with `nullcontext` when we
# support Python 3.10 (`nullcontext` becomes async-aware in 3.10).
# See: https://docs.python.org/3/library/contextlib.html#contextlib.nullcontext |
I added one last comment. When that is done this PR looks good to me. 👍 Thanks for the patience with my pedantic obsession with typing. 😅 |
Looks good to me now. Thank you for your contribution to asyncio-mqtt. 👍 |
Thank you so much for your support! So I can plan: when are you thinking about cutting a new release? |
First thing tomorrow. I'll keep the notification e-mail about this PR in my inbox to remind me. |
I just uploaded v0.12.0 to PyPI. |
This PR applies a backpressure mechanism so that extremely chatty clients don't add congestion to the server. The mechanism is controlled with a
max_concurrent_outgoing_calls
parameter that can be applied to the client during instantiation:max_concurrent_outgoing_calls
value ofNone
means that no back pressure is appliedmax_concurrent_outgoing_calls
value with a positiveint
indicates that no more thanmax_concurrent_outgoing_calls
outgoing calls can happen at any given time.Fixes #29
@frederikaalund Some comments for your review and consideration:
max_concurrent_outgoing_calls
can beNone
(and is so by default) should retain backward compatibility.