Skip to content

Commit

Permalink
Revert r152915. Chapuni's WinWaitReleased refactoring: It doesn't wor…
Browse files Browse the repository at this point in the history
…k for me

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152958 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
fpichet committed Mar 16, 2012
1 parent 748c1ec commit 391c145
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,12 @@ def RemoveForce(f):
except OSError:
pass

def WinWaitReleased(f):
import time, win32file
def WinRename(f_o, f_n):
import time
retry_cnt = 256
while True:
while (True):
try:
h = win32file.CreateFile(
f,
0, # Querying, neither GENERIC_READ nor GENERIC_WRITE
0, # Exclusive
None,
win32file.OPEN_EXISTING,
win32file.FILE_ATTRIBUTE_NORMAL,
None)
h.close()
os.rename(f_o, f_n)
break
except WindowsError, (winerror, strerror):
retry_cnt = retry_cnt - 1
Expand All @@ -53,6 +45,21 @@ def WinWaitReleased(f):
else:
raise

def WinWaitReleased(f):
import random
t = "%s%06d" % (f, random.randint(0, 999999))
RemoveForce(t)
try:
WinRename(f, t) # rename
WinRename(t, f) # restore
except WindowsError, (winerror, strerror):
if winerror in (2, 3):
# 2: ERROR_FILE_NOT_FOUND
# 3: ERROR_PATH_NOT_FOUND
pass
else:
raise

def executeCommand(command, cwd=None, env=None):
p = subprocess.Popen(command, cwd=cwd,
stdin=subprocess.PIPE,
Expand Down

0 comments on commit 391c145

Please sign in to comment.