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.