add psuedocode

Aditya 2023-07-02 10:52:16 +05:30
parent 56bfddab2e
commit 92b2503004

@ -120,8 +120,14 @@ class MyUpdateProcessor(BaseUpdateProcessor):
Application.builder().token('TOKEN').concurrent_updates(MyUpdateProcessor(10)).build() Application.builder().token('TOKEN').concurrent_updates(MyUpdateProcessor(10)).build()
``` ```
The above code processes every `callback_query` update with a delay of 5 seconds for up to 10 updates simultaneously. This is just an example of how to use the `BaseUpdateProcessor` class, there are endless possibilities to this. The above code processes every `callback_query` update with a delay of 5 seconds for up to 10 updates simultaneously. Psuedocode:
See the [documentation](https://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.baseupdateprocessor.html#telegram.ext.BaseUpdateProcessor) for more information. ```python
while not application.update_queue.empty():
update = await application.update_queue.get()
coroutine = application.process_update(update)
asyncio.create_task(do_process_update(update, coroutine))
```
This is just an example of how to use the `BaseUpdateProcessor` class to handle updates in the way you want, there are endless possibilities to this. See the [documentation](https://python-telegram-bot.readthedocs.io/en/latest/telegram.ext.baseupdateprocessor.html#telegram.ext.BaseUpdateProcessor) for more information.
**Note:** The number of concurrently processed updates is limited (the limit defaults to 4096 updates at a time). **Note:** The number of concurrently processed updates is limited (the limit defaults to 4096 updates at a time).
This is a simple measure to avoid e.g. DDOS attacks This is a simple measure to avoid e.g. DDOS attacks