@@ -495,10 +495,13 @@ def __init__(
495
495
496
496
If your app is a command-line app (CLI),
497
497
you would want to persist your http_cache across different CLI runs.
498
+ The persisted file's format may change due to, but not limited to,
499
+ `unstable protocol <https://docs.python.org/3/library/pickle.html#data-stream-format>`_,
500
+ so your implementation shall tolerate unexpected loading errors.
498
501
The following recipe shows a way to do so::
499
502
500
503
# Just add the following lines at the beginning of your CLI script
501
- import sys, atexit, pickle
504
+ import sys, atexit, pickle, logging
502
505
http_cache_filename = sys.argv[0] + ".http_cache"
503
506
try:
504
507
with open(http_cache_filename, "rb") as f:
@@ -509,6 +512,9 @@ def __init__(
509
512
AttributeError, # Cache created by a different version of MSAL
510
513
):
511
514
persisted_http_cache = {} # Recover by starting afresh
515
+ except: # Unexpected exceptions
516
+ logging.exception("You may want to debug this")
517
+ persisted_http_cache = {} # Recover by starting afresh
512
518
atexit.register(lambda: pickle.dump(
513
519
# When exit, flush it back to the file.
514
520
# It may occasionally overwrite another process's concurrent write,
@@ -2012,12 +2018,12 @@ def __init__(
2012
2018
This parameter defaults to None, which means MSAL will not utilize a broker.
2013
2019
2014
2020
New in MSAL Python 1.31.0.
2015
-
2021
+
2016
2022
:param boolean enable_broker_on_linux:
2017
2023
This setting is only effective if your app is running on Linux, including WSL.
2018
2024
This parameter defaults to None, which means MSAL will not utilize a broker.
2019
2025
2020
- New in MSAL Python 1.33.0.
2026
+ New in MSAL Python 1.33.0.
2021
2027
2022
2028
:param boolean enable_broker_on_wsl:
2023
2029
This setting is only effective if your app is running on WSL.
0 commit comments