Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win,test: try again if file unlink fails #284

Merged
merged 1 commit into from
Jan 11, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import threading
import utils
import multiprocessing
import errno

from os.path import join, dirname, abspath, basename, isdir, exists
from datetime import datetime
Expand Down Expand Up @@ -570,11 +571,18 @@ def PrintError(str):


def CheckedUnlink(name):
try:
os.unlink(name)
except OSError, e:
PrintError("os.unlink() " + str(e))

while True:
try:
os.unlink(name)
except OSError, e:
# On Windows unlink() fails if another process (typically a virus scanner
# or the indexing service) has the file open. Those processes keep a
# file open for a short time only, so yield and try again; it'll succeed.
if sys.platform == 'win32' and e.errno == errno.EACCES:
time.sleep(0)
continue
PrintError("os.unlink() " + str(e))
break

def Execute(args, context, timeout=None, env={}):
(fd_out, outname) = tempfile.mkstemp()
Expand Down