mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 04:30:30 +08:00
Change /tmp to platform-specific temporary directory (#7529)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user