mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 17:11:05 +08:00
[docker] Run profiling without sudo (#10388)
* fix profiling for docker * small fixes * use name * do not import pwd on windows
This commit is contained in:
@@ -18,6 +18,10 @@ import ray.gcs_utils
|
||||
import ray.ray_constants as ray_constants
|
||||
import psutil
|
||||
|
||||
pwd = None
|
||||
if sys.platform != "win32":
|
||||
import pwd
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Linux can bind child processes' lifetimes to that of their parents via prctl.
|
||||
@@ -780,3 +784,12 @@ def try_to_symlink(symlink_path, target_path):
|
||||
os.symlink(target_path, symlink_path)
|
||||
except OSError:
|
||||
return
|
||||
|
||||
|
||||
def get_user():
|
||||
if pwd is None:
|
||||
return ""
|
||||
try:
|
||||
return pwd.getpwuid(os.getuid()).pw_name
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user