changeset 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 2db236d25ecd
children 0ecc1f3de581 8198aa2ed20d
files upreckon/win32.py
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/upreckon/win32.py	Sat Jun 04 01:31:55 2011 +0100
+++ b/upreckon/win32.py	Wed Jun 08 20:53:26 2011 +0100
@@ -476,16 +476,15 @@
 		case.process = Popen(*args, **kwargs)
 	except OSError:
 		raise CannotStartTestee(sys.exc_info()[1])
-		case.time_started = clock()
-	# FIXME: how about checking for Escape hits?
-	while True:
+	case.time_started = clock()
+	try:
+		AssignProcessToJobObject(job, case.process._handle)
+	except WindowsError:
 		try:
-			AssignProcessToJobObject(job, case.process._handle)
+			if case.process.poll() is None:
+				raise CannotStartTestee(sys.exc_info()[1])
 		except WindowsError:
-			if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED:
-				time.sleep(0)
-		else:
-			break
+			raise CannotStartTestee(sys.exc_info()[1])
 	if not console_input:
 		if case.maxwalltime:
 			if (WaitForSingleObject(case.process._handle, case.maxwalltime) !=
@@ -553,14 +552,14 @@
 
 
 def kill(process):
-	while True:
+	# Give up after three attempts
+	for i in range(3):
 		try:
 			try:
 				process.terminate()
 			except AttributeError:
 				TerminateProcess(process._handle, 1)
 		except WindowsError:
-			if sys.exc_info()[1].winerror == ERROR_ACCESS_DENIED:
-				time.sleep(0)
+			time.sleep(0)
 		else:
 			break