-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[FEATURE] Customizing concurrent handling of updates #3509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Some more notes:
|
|
Hi, @Bibo-Joshi @clot27 |
The issue is in the backlog and clot will send a PR once they have the time for it. If you like to, you can send a PR yourself. Please leave a short comment in that case so that we can avoid doubled work 🙂 |
Reopening just as a reminder that the wiki pages on orvall architectire and concurrency still need to be updated :) |
What kind of feature are you missing? Where do you notice a shortcoming of PTB?
Setting
ApplicationBuilder.concurrent_updates(True)
allows to process all updates concurrently (up to a specified number at a time). What you can't do is e.g. processing updates from all users & chats concurrently while processing the updates for each user/chat sequentially. Having the possibility for such a mechanism would e.g. allow toConversationHandler
Describe the solution you'd like
BaseThrottler
(other naming suggestions are welcome!). This class shouldasync def process_update(update, coroutine)
whose task it is toawait
at an appropriate time, that may be determined depending on theupdate
asyne def do_process_update
that callsprocess_update
after applying a global semaphore, which enforces the limit in a.SimpleThrottler(BaseThrottler)
(other naming suggestions are welcome) for whichprocess_update
immediately awaits the coroutine, i.e. does not apply any additional throttlingApplication.concurrent_updates(…)
should be as follows:SimpleThrottler
with the respective max overall number of concurrent updatesTrue
will behave as a. with the current default number specified for that caseBaseThrottler
will use that instance for handling concurrencyApplication.concurrent_updates
should return the max overall number of concurrent updates as specified for the throttler in use. The throttler itself may be made available via an additional attribute/propertyDescribe alternatives you've considered
SimpleThrottler
and encourage users to overrideprocess_update
SimpleThrottler
a bit more elaborate by e.g. allowing to sequencify the processing of updates per chat id. In this case, I would vote to go for the interface-class approach as the implementation would surely require more elaborate internals than that ofSimpleThrottler
.Additional context
This idea was already discussed a bit in the early stages of the v20 architecture design but was put on hold, since we first wanted to get the basic structure ready before introducing additional functionality.
Before an attempt on an implementation for this is made, I'd like to get feedback on the idea :)
The text was updated successfully, but these errors were encountered: