From eb1e5fa2cf26233701ccbda3eb8a301ecd418d8c Mon Sep 17 00:00:00 2001 From: Devin Petersohn Date: Fri, 28 Dec 2018 22:53:28 -0800 Subject: [PATCH] Fixing Python2 compatibility issues. Adding inline docs (#3656) --- python/ray/tempfile_services.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/ray/tempfile_services.py b/python/ray/tempfile_services.py index 791b8a257..104c81c5f 100644 --- a/python/ray/tempfile_services.py +++ b/python/ray/tempfile_services.py @@ -66,8 +66,16 @@ def try_to_create_directory(directory_path): # important when multiple people are using the same machine. try: os.chmod(directory_path, 0o0777) - except PermissionError: - pass + except OSError as e: + # Silently suppress the PermissionError that is thrown by the chmod. + # This is done because the user attempting to change the permissions + # on a directory may not own it. The chmod is attempted whether the + # directory is new or not to avoid race conditions. + # ray-project/ray/#3591 + if e.errno in [errno.EACCES, errno.EPERM]: + pass + else: + raise def get_temp_root():