[pypy-svn] r59623 - pypy/build/testrunner

pedronis at codespeak.net pedronis at codespeak.net
Sat Nov 1 14:37:52 CET 2008


Author: pedronis
Date: Sat Nov  1 14:37:49 2008
New Revision: 59623

Modified:
   pypy/build/testrunner/runner.py
Log:
process killing on windows, NB: requires pywin32!

Modified: pypy/build/testrunner/runner.py
==============================================================================
--- pypy/build/testrunner/runner.py	(original)
+++ pypy/build/testrunner/runner.py	Sat Nov  1 14:37:49 2008
@@ -2,12 +2,27 @@
 import py
 from py.compat import subprocess, optparse
 
-
-def _kill(pid, sig):
+if sys.platform == 'win32':
+    PROCESS_TERMINATE = 0x1
     try:
-        os.kill(pid, sig)
-    except OSError:
-        pass
+        import win32api, pywintypes
+    except ImportError:
+        def _kill(pid, sig):
+            print >>sys.stderr, "no process killing support without pywin32"
+    else:
+        def _kill(pid, sig):
+            try:
+                proch = win32api.OpenProcess(PROCESS_TERMINATE, 0, pid)
+                win32api.TerminateProcess(proch, 1)
+                win32api.CloseHandle(proch)
+            except pywintypes.error, e:
+                pass
+else:
+    def _kill(pid, sig):
+        try:
+            os.kill(pid, sig)
+        except OSError:
+            pass
 
 def run(args, cwd, out, timeout=None):
     f = out.open('w')



More information about the Pypy-commit mailing list