Skip to content

[FEATURE/DISCUSSION]: Allow fine tuning of persistence setup #2524

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

Closed
Bibo-Joshi opened this issue May 15, 2021 · 4 comments
Closed

[FEATURE/DISCUSSION]: Allow fine tuning of persistence setup #2524

Bibo-Joshi opened this issue May 15, 2021 · 4 comments
Milestone

Comments

@Bibo-Joshi
Copy link
Member

Bibo-Joshi commented May 15, 2021

There are two places in the current persistence setup where I think we can offer more customization for advanced users. All of this are just first ideas and up for discussion. If the dev team doesn't like the (use case value)/(maintenance workload) ratio, I'd be fine with not doing this.

  1. Edit: We're dropping insert/replace_data see Drop BasePersistence.insert/replace_bot #2882 .

    Original comment:
    We currently pass all data that goes through the persistence setup through replace/insert_bot. While this is the safest way to make sure no Bot instance gets serialized, it can also introduce some overhead which could get noticable when you have large, nested data structures in your chat/bot/user_data or are handling many updates. Adanced users will know where in their data they have bot instances that should get replaced. So we could offer settings like replace_bots_in_chat/bot/user_data (defaulting to True) and only call replace/insert_data when necessary.

    One should note that we'd have to re-indroduce deepcopy into the built-in persistence classes (depending on the replace_bots_in_* settings, that is). See Customize context #2262 (comment)

  2. Adjust calling of update_persistence #2285 already made an effort to reduce the calls of Dispatcher.update_persistence. Still, updating after every update (or even handler call in case you're using run_async) might be unecessary, especially when you're getting updates frequently. Similarly to PicklePersistence.on_flush which allows users to control how often PP writes to file, we would add a flag telling Dispatcher to never automatically call Dispatcher.update_persistence at runtime (only on shutdown). Then users can call Dispatcher.update_persistence manually to their liking.

@Bibo-Joshi Bibo-Joshi added enhancement 🛠 refactor change type: refactor 🛠 breaking change type: breaking labels May 15, 2021
@Bibo-Joshi Bibo-Joshi added this to the v14 milestone May 15, 2021
@Bibo-Joshi Bibo-Joshi removed 🛠 breaking change type: breaking 🛠 refactor change type: refactor labels May 15, 2021
@Poolitzer
Copy link
Member

I like both of these suggestions. Since we redesign a lot for 14 anyway, and the resulting maintenance after doing it once shouldn't be too bad,

@Bibo-Joshi Bibo-Joshi added ℹ️ good-first-issue information: good-first-issue hacktoberfest and removed ℹ️ good-first-issue information: good-first-issue labels Sep 17, 2021
@Bibo-Joshi Bibo-Joshi mentioned this issue Nov 2, 2021
3 tasks
@Bibo-Joshi
Copy link
Member Author

Got started on the first part of this in the https://github.com/python-telegram-bot/python-telegram-bot/tree/customize-replace-insert-bot branch. But we're currently re-evaluating if we want to proceed this.

second part may be independent.

@Bibo-Joshi
Copy link
Member Author

closed by #2893

@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Bibo-Joshi @Poolitzer and others