changeset 21880:518052de60d5

handle race creating a symlink in mx
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 17:23:42 +0200
parents 90fd69243227
children 3b5c9d5bfcaa
files mxtool/mx.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Tue Jun 09 12:50:43 2015 +0200
+++ b/mxtool/mx.py	Tue Jun 09 17:23:42 2015 +0200
@@ -651,7 +651,15 @@
         if canSymlink and 'symlink' in dir(os):
             if exists(path):
                 os.unlink(path)
-            os.symlink(cachePath, path)
+            try:
+                os.symlink(cachePath, path)
+            except OSError as e:
+                # When doing parallel building, the symlink can fail
+                # if another thread wins the race to create the symlink
+                if not exists(path):
+                    # It was some other error
+                    raise e
+
         else:
             shutil.copy(cachePath, path)