Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/win32.py @ 157:5f9e6121161a
Second attempt to work around unwarranted ERROR_ACCESS_DENIED on Windows
Also fixed an indentation error in win32 apparently caused by a bug
in my text editor.
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Wed, 08 Jun 2011 20:53:26 +0100 |
parents | f8041e1e4d0d |
children | ebb35960b5bc |
comparison
equal
deleted
inserted
replaced
156:2db236d25ecd | 157:5f9e6121161a |
---|---|
474 SetInformationJobObject(job, JobObjectExtendedLimitInformation, limits) | 474 SetInformationJobObject(job, JobObjectExtendedLimitInformation, limits) |
475 try: | 475 try: |
476 case.process = Popen(*args, **kwargs) | 476 case.process = Popen(*args, **kwargs) |
477 except OSError: | 477 except OSError: |
478 raise CannotStartTestee(sys.exc_info()[1]) | 478 raise CannotStartTestee(sys.exc_info()[1]) |
479 case.time_started = clock() | 479 case.time_started = clock() |
480 # FIXME: how about checking for Escape hits? | 480 try: |
481 while True: | 481 AssignProcessToJobObject(job, case.process._handle) |
482 except WindowsError: | |
482 try: | 483 try: |
483 AssignProcessToJobObject(job, case.process._handle) | 484 if case.process.poll() is None: |
485 raise CannotStartTestee(sys.exc_info()[1]) | |
484 except WindowsError: | 486 except WindowsError: |
485 if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED: | 487 raise CannotStartTestee(sys.exc_info()[1]) |
486 time.sleep(0) | |
487 else: | |
488 break | |
489 if not console_input: | 488 if not console_input: |
490 if case.maxwalltime: | 489 if case.maxwalltime: |
491 if (WaitForSingleObject(case.process._handle, case.maxwalltime) != | 490 if (WaitForSingleObject(case.process._handle, case.maxwalltime) != |
492 WAIT_OBJECT_0): | 491 WAIT_OBJECT_0): |
493 raise WallTimeLimitExceeded | 492 raise WallTimeLimitExceeded |
551 if counters.PeakPagefileUsage > case.maxmemory * 1048576: | 550 if counters.PeakPagefileUsage > case.maxmemory * 1048576: |
552 raise MemoryLimitExceeded | 551 raise MemoryLimitExceeded |
553 | 552 |
554 | 553 |
555 def kill(process): | 554 def kill(process): |
556 while True: | 555 # Give up after three attempts |
556 for i in range(3): | |
557 try: | 557 try: |
558 try: | 558 try: |
559 process.terminate() | 559 process.terminate() |
560 except AttributeError: | 560 except AttributeError: |
561 TerminateProcess(process._handle, 1) | 561 TerminateProcess(process._handle, 1) |
562 except WindowsError: | 562 except WindowsError: |
563 if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED: | 563 time.sleep(0) |
564 time.sleep(0) | |
565 else: | 564 else: |
566 break | 565 break |