From 3827ccb5dd6c493e94cc94d8064177a564225939 Mon Sep 17 00:00:00 2001 From: hlu1 <14827759+hlu1@users.noreply.github.com> Date: Tue, 28 Jan 2020 17:58:36 -0800 Subject: [PATCH] [Python] Replace os.path.exists with try...except...else (#4784) --- python/tvm/contrib/pickle_memoize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/tvm/contrib/pickle_memoize.py b/python/tvm/contrib/pickle_memoize.py index 5c16419..6e72aba 100644 --- a/python/tvm/contrib/pickle_memoize.py +++ b/python/tvm/contrib/pickle_memoize.py @@ -40,8 +40,12 @@ class Cache(object): cache_by_key = {} def __init__(self, key, save_at_exit): cache_dir = ".pkl_memoize_py{0}".format(sys.version_info[0]) - if not os.path.exists(cache_dir): + try: os.mkdir(cache_dir) + except FileExistsError: + pass + else: + self.cache = {} self.path = os.path.join(cache_dir, key) if os.path.exists(self.path): try: -- 2.7.4