Skip to content

Commit 3827ccb

Browse files
authored
[Python] Replace os.path.exists with try...except...else (#4784)
1 parent 9c383f6 commit 3827ccb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/tvm/contrib/pickle_memoize.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ class Cache(object):
4040
cache_by_key = {}
4141
def __init__(self, key, save_at_exit):
4242
cache_dir = ".pkl_memoize_py{0}".format(sys.version_info[0])
43-
if not os.path.exists(cache_dir):
43+
try:
4444
os.mkdir(cache_dir)
45+
except FileExistsError:
46+
pass
47+
else:
48+
self.cache = {}
4549
self.path = os.path.join(cache_dir, key)
4650
if os.path.exists(self.path):
4751
try:

0 commit comments

Comments
 (0)