You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/10/08 17:30:15 UTC

[GitHub] szha commented on a change in pull request #12572: Make Gluon download function to be atomic

szha commented on a change in pull request #12572: Make Gluon download function to be atomic
URL: https://github.com/apache/incubator-mxnet/pull/12572#discussion_r223442274
 
 

 ##########
 File path: python/mxnet/gluon/utils.py
 ##########
 @@ -195,6 +197,59 @@ def check_sha1(filename, sha1_hash):
     return sha1.hexdigest() == sha1_hash
 
 
+if not sys.platform.startswith('win32'):
+    # refer to https://github.com/untitaker/python-atomicwrites
+    def _replace_atomic(src, dst):
+        """Implement atomic os.replace with linux and OSX. Internal use only"""
+        try:
+            os.rename(src, dst)
+        except OSError:
+            try:
+                os.remove(src)
+            except OSError:
+                pass
+            raise OSError(
 
 Review comment:
   include this part in a finally block

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services