# HG changeset patch # User Oleg Oshmyan # Date 1307016329 -3600 # Node ID aa343ff41c27e98ec93c8f1ec43732146771bc94 # Parent 37955420fd664f5231f73b4d376a08c2361f2cb3 Attempted to work around unwarranted ERROR_ACCESS_DENIED on Win32 diff -r 37955420fd66 -r aa343ff41c27 upreckon/win32.py --- 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