Skip to content

Commit

Permalink
Fix race conditions in _permissions() (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Dunn authored and jonmmease committed Apr 8, 2019
1 parent b13b2ba commit 133df4d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions plotly/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@
def _permissions():
try:
if not os.path.exists(PLOTLY_DIR):
os.mkdir(PLOTLY_DIR)
try:
os.mkdir(PLOTLY_DIR)
except Exception:
# in case of race
if not os.path.isdir(PLOTLY_DIR):
raise
with open(TEST_FILE, 'w') as f:
f.write('testing\n')
os.remove(TEST_FILE)
try:
os.remove(TEST_FILE)
except Exception:
pass
return True
except:
except Exception: # Do not trap KeyboardInterrupt.
return False


Expand Down

0 comments on commit 133df4d

Please sign in to comment.