Skip to content

Feature/region #399

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

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions qiniu/region.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

import logging
import os
import time
import requests
Expand Down Expand Up @@ -127,6 +127,9 @@ def get_bucket_hosts_to_cache(self, key, home_dir):
if (len(self.host_cache) == 0):
self.host_cache_from_file(home_dir)

if self.host_cache == {}:
return ret

if (not (key in self.host_cache)):
return ret

Expand All @@ -147,8 +150,11 @@ def host_cache_from_file(self, home_dir):
if not os.path.isfile(path):
return None
with open(path, 'r') as f:
bucket_hosts = compat.json.load(f)
self.host_cache = bucket_hosts
try:
bucket_hosts = compat.json.load(f)
self.host_cache = bucket_hosts
except Exception as e:
logging.error(e)
f.close()
return

Expand Down