Mercurial > ~astiob > upreckon > hgweb
changeset 148:aa343ff41c27
Attempted to work around unwarranted ERROR_ACCESS_DENIED on Win32
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Thu, 02 Jun 2011 13:05:29 +0100 |
parents | 37955420fd66 |
children | a1286da36d29 |
files | upreckon/win32.py |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/upreckon/win32.py Sat May 28 19:54:03 2011 +0100 +++ b/upreckon/win32.py Thu Jun 02 13:05:29 2011 +0100 @@ -151,6 +151,7 @@ LPFILETIME = POINTER(FILETIME) SIZE_T = ULONG_PTR = WPARAM ULONGLONG = c_ulonglong +ERROR_ACCESS_DENIED = 5 try: unicode @@ -475,8 +476,16 @@ case.process = Popen(*args, **kwargs) except OSError: raise CannotStartTestee(sys.exc_info()[1]) - case.time_started = clock() - AssignProcessToJobObject(job, case.process._handle) + case.time_started = clock() + # FIXME: how about checking for Escape hits? + while True: + try: + AssignProcessToJobObject(job, case.process._handle) + except WindowsError: + if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED: + time.sleep(0) + else: + break if not console_input: if case.maxwalltime: if (WaitForSingleObject(case.process._handle, case.maxwalltime) != @@ -544,14 +553,14 @@ def kill(process): - # Give up after three attempts - for i in range(3): + while True: try: try: process.terminate() except AttributeError: TerminateProcess(process._handle, 1) except WindowsError: - time.sleep(0) + if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED: + time.sleep(0) else: break