Skip to content

Commit 8f2fffd

Browse files
authored
Merge pull request #399 from qiniu/feature/region
Feature/region
2 parents 2689f34 + 0461a43 commit 8f2fffd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

qiniu/region.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
2+
import logging
33
import os
44
import time
55
import requests
@@ -127,6 +127,9 @@ def get_bucket_hosts_to_cache(self, key, home_dir):
127127
if (len(self.host_cache) == 0):
128128
self.host_cache_from_file(home_dir)
129129

130+
if self.host_cache == {}:
131+
return ret
132+
130133
if (not (key in self.host_cache)):
131134
return ret
132135

@@ -147,8 +150,11 @@ def host_cache_from_file(self, home_dir):
147150
if not os.path.isfile(path):
148151
return None
149152
with open(path, 'r') as f:
150-
bucket_hosts = compat.json.load(f)
151-
self.host_cache = bucket_hosts
153+
try:
154+
bucket_hosts = compat.json.load(f)
155+
self.host_cache = bucket_hosts
156+
except Exception as e:
157+
logging.error(e)
152158
f.close()
153159
return
154160

0 commit comments

Comments
 (0)