Change /tmp to platform-specific temporary directory (#7529)

This commit is contained in:
mehrdadn
2020-03-16 18:10:14 -07:00
committed by GitHub
parent 797e6cfc2a
commit a0700e2f86
27 changed files with 289 additions and 80 deletions
+15
View File
@@ -8,6 +8,7 @@ import os
import six
import subprocess
import sys
import tempfile
import threading
import time
import uuid
@@ -29,6 +30,20 @@ win32_job = None
win32_AssignProcessToJobObject = None
def get_user_temp_dir():
if sys.platform.startswith("darwin") or sys.platform.startswith("linux"):
# Ideally we wouldn't need this fallback, but keep it for now for
# for compatibility
tempdir = os.path.join(os.sep, "tmp")
else:
tempdir = tempfile.gettempdir()
return tempdir
def get_ray_temp_dir():
return os.path.join(get_user_temp_dir(), "ray")
def _random_string():
id_hash = hashlib.sha1()
id_hash.update(uuid.uuid4().bytes)