Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/win32.py @ 226:ebb35960b5bc 2.03
Third attempt to work around unwarranted ERROR_ACCESS_DENIED on Windows
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Wed, 06 Jun 2012 20:22:18 +0100 |
parents | 5f9e6121161a |
children | acd70a60bc17 |
comparison
equal
deleted
inserted
replaced
225:a78349b7bbc4 | 226:ebb35960b5bc |
---|---|
1 # Copyright (c) 2010-2011 Chortos-2 <chortos@inbox.lv> | 1 # Copyright (c) 2010-2012 Chortos-2 <chortos@inbox.lv> |
2 | 2 |
3 from __future__ import division, with_statement | 3 from __future__ import division, with_statement |
4 | 4 |
5 from .compat import * | 5 from .compat import * |
6 from .exceptions import * | 6 from .exceptions import * |
144 _CloseHandle(_HANDLE(self.handle)) | 144 _CloseHandle(_HANDLE(self.handle)) |
145 self.handle = None | 145 self.handle = None |
146 __del__ = Close | 146 __del__ = Close |
147 | 147 |
148 CHAR = c_char | 148 CHAR = c_char |
149 CREATE_BREAKAWAY_FROM_JOB = 0x01000000 | |
149 INVALID_HANDLE_VALUE = HANDLE(-1).value | 150 INVALID_HANDLE_VALUE = HANDLE(-1).value |
150 LPDWORD = POINTER(DWORD) | 151 LPDWORD = POINTER(DWORD) |
151 LPFILETIME = POINTER(FILETIME) | 152 LPFILETIME = POINTER(FILETIME) |
152 SIZE_T = ULONG_PTR = WPARAM | 153 SIZE_T = ULONG_PTR = WPARAM |
153 ULONGLONG = c_ulonglong | 154 ULONGLONG = c_ulonglong |
470 LimitFlags=flags, | 471 LimitFlags=flags, |
471 ), | 472 ), |
472 ProcessMemoryLimit=ceil((case.maxmemory or 0)*1048576), | 473 ProcessMemoryLimit=ceil((case.maxmemory or 0)*1048576), |
473 ) | 474 ) |
474 SetInformationJobObject(job, JobObjectExtendedLimitInformation, limits) | 475 SetInformationJobObject(job, JobObjectExtendedLimitInformation, limits) |
476 kwargs['creationflags'] = kwargs.get('creationflags', 0) | CREATE_BREAKAWAY_FROM_JOB | |
475 try: | 477 try: |
476 case.process = Popen(*args, **kwargs) | 478 case.process = Popen(*args, **kwargs) |
477 except OSError: | 479 except OSError: |
478 raise CannotStartTestee(sys.exc_info()[1]) | 480 raise CannotStartTestee(sys.exc_info()[1]) |
479 case.time_started = clock() | 481 case.time_started = clock() |
480 try: | 482 while True: |
481 AssignProcessToJobObject(job, case.process._handle) | |
482 except WindowsError: | |
483 try: | 483 try: |
484 if case.process.poll() is None: | 484 AssignProcessToJobObject(job, case.process._handle) |
485 raise CannotStartTestee(sys.exc_info()[1]) | |
486 except WindowsError: | 485 except WindowsError: |
487 raise CannotStartTestee(sys.exc_info()[1]) | 486 e = sys.exc_info()[1] |
487 try: | |
488 if case.process.poll() is not None: | |
489 break | |
490 except WindowsError: | |
491 e = sys.exc_info()[1] | |
492 if e.winerror != ERROR_ACCESS_DENIED: | |
493 raise CannotStartTestee(e) | |
494 time.sleep(0) | |
495 else: | |
496 break | |
488 if not console_input: | 497 if not console_input: |
489 if case.maxwalltime: | 498 if case.maxwalltime: |
490 if (WaitForSingleObject(case.process._handle, case.maxwalltime) != | 499 if (WaitForSingleObject(case.process._handle, case.maxwalltime) != |
491 WAIT_OBJECT_0): | 500 WAIT_OBJECT_0): |
492 raise WallTimeLimitExceeded | 501 raise WallTimeLimitExceeded |