From 82a506ea97779a1a1d9adc0e140675f7718adfcf Mon Sep 17 00:00:00 2001 From: Bibo-Joshi Date: Wed, 7 Oct 2020 21:37:42 +0200 Subject: [PATCH] Updated Code snippets (markdown) --- Code-snippets.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Code-snippets.md b/Code-snippets.md index 56c37bf..36b0421 100644 --- a/Code-snippets.md +++ b/Code-snippets.md @@ -613,6 +613,9 @@ if __name__ == '__main__': Version 12 and up includes tools for [making your bot persistent](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Making-your-bot-persistent). #### Save and load jobs using pickle + +**WARNING:** This snippet was written for v12.x and can't be used with v13+. + The following snippet pickles the jobs in the job queue periodically and on bot shutdown, and unpickles and queues them again on startup. Since pickle doesn't support threading primitives, therefore their values and states are extracted (this information may change in the future, always check the `Job` documentation). **Note:** `Job` is not yet safe for threads so eventually some special condition may occur. In a previous example, the content of `Job` was modified which resulted in some asynchronous processing errors; now the content of `Job` is extracted without modifying it which is much more safe.