Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/win32.py @ 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 | d5b6708c1955 |
children | f8041e1e4d0d |
comparison
equal
deleted
inserted
replaced
147:37955420fd66 | 148:aa343ff41c27 |
---|---|
149 INVALID_HANDLE_VALUE = HANDLE(-1).value | 149 INVALID_HANDLE_VALUE = HANDLE(-1).value |
150 LPDWORD = POINTER(DWORD) | 150 LPDWORD = POINTER(DWORD) |
151 LPFILETIME = POINTER(FILETIME) | 151 LPFILETIME = POINTER(FILETIME) |
152 SIZE_T = ULONG_PTR = WPARAM | 152 SIZE_T = ULONG_PTR = WPARAM |
153 ULONGLONG = c_ulonglong | 153 ULONGLONG = c_ulonglong |
154 ERROR_ACCESS_DENIED = 5 | |
154 | 155 |
155 try: | 156 try: |
156 unicode | 157 unicode |
157 except NameError: | 158 except NameError: |
158 LPCTSTR = LPCWSTR | 159 LPCTSTR = LPCWSTR |
473 SetInformationJobObject(job, JobObjectExtendedLimitInformation, limits) | 474 SetInformationJobObject(job, JobObjectExtendedLimitInformation, limits) |
474 try: | 475 try: |
475 case.process = Popen(*args, **kwargs) | 476 case.process = Popen(*args, **kwargs) |
476 except OSError: | 477 except OSError: |
477 raise CannotStartTestee(sys.exc_info()[1]) | 478 raise CannotStartTestee(sys.exc_info()[1]) |
478 case.time_started = clock() | 479 case.time_started = clock() |
479 AssignProcessToJobObject(job, case.process._handle) | 480 # FIXME: how about checking for Escape hits? |
481 while True: | |
482 try: | |
483 AssignProcessToJobObject(job, case.process._handle) | |
484 except WindowsError: | |
485 if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED: | |
486 time.sleep(0) | |
487 else: | |
488 break | |
480 if not console_input: | 489 if not console_input: |
481 if case.maxwalltime: | 490 if case.maxwalltime: |
482 if (WaitForSingleObject(case.process._handle, case.maxwalltime) != | 491 if (WaitForSingleObject(case.process._handle, case.maxwalltime) != |
483 WAIT_OBJECT_0): | 492 WAIT_OBJECT_0): |
484 raise WallTimeLimitExceeded | 493 raise WallTimeLimitExceeded |
542 if counters.PeakPagefileUsage > case.maxmemory * 1048576: | 551 if counters.PeakPagefileUsage > case.maxmemory * 1048576: |
543 raise MemoryLimitExceeded | 552 raise MemoryLimitExceeded |
544 | 553 |
545 | 554 |
546 def kill(process): | 555 def kill(process): |
547 # Give up after three attempts | 556 while True: |
548 for i in range(3): | |
549 try: | 557 try: |
550 try: | 558 try: |
551 process.terminate() | 559 process.terminate() |
552 except AttributeError: | 560 except AttributeError: |
553 TerminateProcess(process._handle, 1) | 561 TerminateProcess(process._handle, 1) |
554 except WindowsError: | 562 except WindowsError: |
555 time.sleep(0) | 563 if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED: |
564 time.sleep(0) | |
556 else: | 565 else: |
557 break | 566 break |