@@ -300,7 +300,8 @@ def _lock_file_path(self):
300
300
memo_cache = {},
301
301
persist_path = os .path .join (
302
302
tempfile .gettempdir (),
303
- 'qn-py-sdk-regions-cache.jsonl'
303
+ 'qn-py-sdk' ,
304
+ 'regions-cache.jsonl'
304
305
),
305
306
last_shrink_at = datetime .datetime .fromtimestamp (0 ),
306
307
shrink_interval = datetime .timedelta (days = 1 ),
@@ -520,8 +521,18 @@ def __init__(
520
521
persist_path = kwargs .get ('persist_path' , None )
521
522
last_shrink_at = datetime .datetime .fromtimestamp (0 )
522
523
if persist_path is None :
523
- persist_path = _global_cache_scope .persist_path
524
- last_shrink_at = _global_cache_scope .last_shrink_at
524
+ cache_dir = os .path .dirname (_global_cache_scope .persist_path )
525
+ try :
526
+ # make sure the cache dir is available for all users.
527
+ # we can not use the '/tmp' dir directly on linux,
528
+ # because the permission is 0o1777
529
+ os .makedirs (cache_dir , exist_ok = True )
530
+ os .chmod (cache_dir , 0o777 )
531
+ persist_path = _global_cache_scope .persist_path
532
+ last_shrink_at = _global_cache_scope .last_shrink_at
533
+ except Exception as err :
534
+ logging .warning (
535
+ 'failed to create cache dir %s. error: %s' , cache_dir , err )
525
536
526
537
shrink_interval = kwargs .get ('shrink_interval' , None )
527
538
if shrink_interval is None :
0 commit comments