win,test: try again if file unlink fails
Now that parallel tests are enabled, the test runner spits out a ton of 'access denied' errors while running the tests. These happen because a virus scanner or the indexing service temporarily open the file after it has been updated, and the test runner tries to unlink() them at the same time. This patch resolves this issue by attempting to unlink the file until it succeeds. PR-URL: https://github.com/iojs/io.js/pull/284 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Родитель
7f9a6c6213
Коммит
b57e9a9973
|
@ -41,6 +41,7 @@ import time
|
|||
import threading
|
||||
import utils
|
||||
import multiprocessing
|
||||
import errno
|
||||
|
||||
from os.path import join, dirname, abspath, basename, isdir, exists
|
||||
from datetime import datetime
|
||||
|
@ -570,11 +571,18 @@ def PrintError(str):
|
|||
|
||||
|
||||
def CheckedUnlink(name):
|
||||
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()
|
||||
|
|
Загрузка…
Ссылка в новой задаче