Skip to content

Commit

Permalink
remove exp_backoff_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed Jun 17, 2016
1 parent 5188cae commit c53dbb8
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions conda/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import tarfile
import time
import traceback
import random
from os.path import (abspath, basename, dirname, isdir, isfile, islink,
join, relpath, normpath)

Expand Down Expand Up @@ -225,21 +224,6 @@ def warn_failed_remove(function, path, exc_info):
log.warn("Cannot remove, unknown reason: {0}".format(path))


def exp_backoff_fn(fn, *args):
"""Mostly for retrying file operations that fail on Windows due to virus scanners"""
max_retries = 5
for n in range(max_retries):
try:
result = fn(*args)
except Exception as e:
log.debug(repr(e))
if n == max_retries-1:
raise
time.sleep((2 ** n) + (random.randint(0, 1000) / 1000))
else:
return result


def rm_rf(path, max_retries=5, trash=True):
"""
Completely delete path
Expand Down Expand Up @@ -418,7 +402,7 @@ def update_prefix(path, new_prefix, placeholder=prefix_placeholder, mode='text')
st = os.lstat(path)
# Remove file before rewriting to avoid destroying hard-linked cache
os.remove(path)
with exp_backoff_fn(open, path, 'wb') as fo:
with open(path, 'wb') as fo:
fo.write(data)
os.chmod(path, stat.S_IMODE(st.st_mode))

Expand Down Expand Up @@ -842,7 +826,7 @@ def extract(dist):
with tarfile.open(fname) as t:
t.extractall(path=temp_path)
rm_rf(path)
exp_backoff_fn(os.rename, temp_path, path)
os.rename(temp_path, path)
if sys.platform.startswith('linux') and os.getuid() == 0:
# When extracting as root, tarfile will by restore ownership
# of extracted files. However, we want root to be the owner
Expand Down

0 comments on commit c53dbb8

Please sign in to comment.