Skip to content

Commit

Permalink
fix(utility): fix the FileExistsError when using cache with multiprocess
Browse files Browse the repository at this point in the history
When using cache with multiprocess, the result will not necessarily stay
true after asserting `os.path.exists(cache_path) == True`.
Add `exist_ok` when calling `os.makedirs` to fix this problem.

PR Closed: #1113
  • Loading branch information
Lee-000 committed Nov 19, 2021
1 parent 5cacaf5 commit 5d5cf30
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tensorbay/utility/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ def open(self) -> Union[HTTPResponse, BufferedReader]:

if not os.path.exists(cache_path):
dirname = os.path.dirname(cache_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
os.makedirs(dirname, exist_ok=True)

with self._urlopen() as fp:
with open(cache_path, "wb") as cache:
Expand Down

0 comments on commit 5d5cf30

Please sign in to comment.