Title: [FEATURE] Customizing concurrent handling of updates · Issue #3509 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: [FEATURE] Customizing concurrent handling of updates · Issue #3509 · python-telegram-bot/python-telegram-bot
X Title: [FEATURE] Customizing concurrent handling of updates · Issue #3509 · python-telegram-bot/python-telegram-bot
Description: 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...
Open Graph Description: 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 num...
X Description: 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 num...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/3509
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[FEATURE] Customizing concurrent handling of updates","articleBody":"### What kind of feature are you missing? Where do you notice a shortcoming of PTB?\n\nSetting `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 to\r\n\r\n* handle updates concurrently except those that are revelant for stateful handlers such as `ConversationHandler`\r\n* apply a rate-limiting mechanism for users by delaying processing of their updates\r\n* prioritizing certain types of updates for handling, e.g. inline/callback queries over regular messages\n\n### Describe the solution you'd like\n\n1. Introduce an interface class `BaseThrottler` (other naming suggestions are welcome!). This class should\r\n 1. accept an integer that specifies the maximum overall number of updates that may be processed concurrently\r\n 2. have a single abstract method `async def process_update(update, coroutine)` whose task it is to `await` at an appropriate time, that may be determined depending on the `update`\r\n 3. have a single non-abstract method `asyne def do_process_update` that calls `process_update` after applying a global semaphore, which enforces the limit in a.\r\n2. Introduce a class `SimpleThrottler(BaseThrottler)` (other naming suggestions are welcome) for which `process_update` immediately awaits the coroutine, i.e. does not apply any additional throttling\r\n3. The behavior of `Application.concurrent_updates(…)` should be as follows:\r\n 1. passing an int will make use of the `SimpleThrottler` with the respective max overall number of concurrent updates\r\n 2. passing `True` will behave as a. with the current default number specified for that case\r\n 3. passing an instace of `BaseThrottler` will use that instance for handling concurrency\r\n4. `Application.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/property\n\n### Describe alternatives you've considered\n\n* Instead of an interface class, one could directly provide the `SimpleThrottler` and encourage users to override `process_update`\r\n* One could make `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 of `SimpleThrottler`.\n\n### Additional context\n\nThis 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.\r\n\r\nBefore an attempt on an implementation for this is made, I'd like to get feedback on the idea :)","author":{"url":"https://github.com/Bibo-Joshi","@type":"Person","name":"Bibo-Joshi"},"datePublished":"2023-01-19T21:03:24Z","url":"https://github.com/python-telegram-bot/python-telegram-bot/issues/3509"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dde86042-ff25-4e3e-70f8-76c349766781 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BE8:2A98A:176F082:1D7427F:6B027A3F |
| html-safe-nonce | 52e7a1d4b2dfa56d81a8298e62bac80faeee2a2bf9446a618869420a46d3b47c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkU4OjJBOThBOjE3NkYwODI6MUQ3NDI3Rjo2QjAyN0EzRiIsInZpc2l0b3JfaWQiOiIxMDIyNzE1Mzg1MjMwODE3ODU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 038a8202bdffd588aa053fa148010ebd370e77be361b521cc6ea29c09055a4e0 |
| hovercard-subject-tag | issue:1549939381 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-telegram-bot/python-telegram-bot/3509/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4af0fb3add95522f09a0e057e3f9796ada2ebf2fb12631eb86398e7976f5ef53/python-telegram-bot/python-telegram-bot/issues/3509 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4af0fb3add95522f09a0e057e3f9796ada2ebf2fb12631eb86398e7976f5ef53/python-telegram-bot/python-telegram-bot/issues/3509 |
| og:image:alt | 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 num... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Bibo-Joshi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git |
| octolytics-dimension-user_id | 16178365 |
| octolytics-dimension-user_login | python-telegram-bot |
| octolytics-dimension-repository_id | 38696925 |
| octolytics-dimension-repository_nwo | python-telegram-bot/python-telegram-bot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38696925 |
| octolytics-dimension-repository_network_root_nwo | python-telegram-bot/python-telegram-bot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width