Skip to content

Commit

Permalink
Still trying to avoid removing "in use" files on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 11, 2015
1 parent 592ee70 commit 1c0ba04
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions pip_accel/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
import subprocess
import sys
import tempfile
import time
import unittest

# External dependencies.
import coloredlogs
from cached_property import cached_property
from humanfriendly import coerce_boolean, compact, concatenate
from humanfriendly import Timer, coerce_boolean, compact, concatenate
from pip.commands.install import InstallCommand
from pip.exceptions import DistributionNotFound

Expand Down Expand Up @@ -849,9 +850,19 @@ def wipe_directory(pathname):
:param pathname: The directory's pathname (a string).
"""
if os.path.isdir(pathname):
shutil.rmtree(pathname)
os.makedirs(pathname)
timer = Timer()
while True:
try:
if os.path.isdir(pathname):
shutil.rmtree(pathname)
os.makedirs(pathname)
return
except Exception:
if timer.elapsed_time < 60:
logger.warning("Got error wiping directory (%s), retrying ..", pathname)
time.sleep(1)
else:
raise


def uninstall_through_subprocess(package_name):
Expand Down

0 comments on commit 1c0ba04

Please sign in to comment.