From d0e594f9dbdb3cf19a8b4e255b59f7632be571e2 Mon Sep 17 00:00:00 2001 From: Dima Date: Thu, 2 Jan 2020 09:45:48 +1100 Subject: [PATCH] Releasing file lock --- src/transformers/file_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/transformers/file_utils.py b/src/transformers/file_utils.py index 60cc9baa6c..8788c75acc 100644 --- a/src/transformers/file_utils.py +++ b/src/transformers/file_utils.py @@ -388,13 +388,13 @@ def get_from_cache( # we are copying the file before closing it, so flush to avoid truncation temp_file.flush() - logger.info("storing %s in cache at %s", url, cache_path) - os.rename(temp_file.name, cache_path) + logger.info("storing %s in cache at %s", url, cache_path) + os.rename(temp_file.name, cache_path) - logger.info("creating metadata file for %s", cache_path) - meta = {"url": url, "etag": etag} - meta_path = cache_path + ".json" - with open(meta_path, "w") as meta_file: - json.dump(meta, meta_file) + logger.info("creating metadata file for %s", cache_path) + meta = {"url": url, "etag": etag} + meta_path = cache_path + ".json" + with open(meta_path, "w") as meta_file: + json.dump(meta, meta_file) return cache_path