mirror of
https://github.com/clearml/clearml
synced 2025-04-16 13:33:10 +00:00
Fix #1348
This commit is contained in:
parent
036d7b6ef2
commit
23fd598a71
@ -257,6 +257,7 @@ class Artifacts(object):
|
|||||||
max_preview_size_bytes = 65536
|
max_preview_size_bytes = 65536
|
||||||
|
|
||||||
_flush_frequency_sec = 300.
|
_flush_frequency_sec = 300.
|
||||||
|
_max_tmp_file_replace_attemps = 3
|
||||||
# notice these two should match
|
# notice these two should match
|
||||||
_save_format = '.csv.gz'
|
_save_format = '.csv.gz'
|
||||||
_compression = 'gzip'
|
_compression = 'gzip'
|
||||||
@ -1138,6 +1139,20 @@ class Artifacts(object):
|
|||||||
temp_folder, prefix, suffix = self._temp_files_lookup.pop(local_filename)
|
temp_folder, prefix, suffix = self._temp_files_lookup.pop(local_filename)
|
||||||
fd, temp_filename = mkstemp(prefix=prefix, suffix=suffix)
|
fd, temp_filename = mkstemp(prefix=prefix, suffix=suffix)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
|
for i in range(self._max_tmp_file_replace_attemps):
|
||||||
|
try:
|
||||||
|
os.replace(local_filename, temp_filename)
|
||||||
|
break
|
||||||
|
except PermissionError:
|
||||||
|
LoggerRoot.get_base_logger().warning(
|
||||||
|
"Failed to replace {} with {}. Attemps left: {}".format(
|
||||||
|
local_filename, temp_filename, self._max_tmp_file_replace_attemps - i
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# final attempt, and if it fails, throw an exception
|
||||||
|
# exception could be thrown on some Windows systems
|
||||||
os.replace(local_filename, temp_filename)
|
os.replace(local_filename, temp_filename)
|
||||||
local_filename = temp_filename
|
local_filename = temp_filename
|
||||||
os.rmdir(temp_folder)
|
os.rmdir(temp_folder)
|
||||||
|
Loading…
Reference in New Issue
Block a user