[py-svn] r39655 - in py/trunk/py/misc: . testing
hpk at codespeak.net
hpk at codespeak.net
Fri Mar 2 12:00:34 CET 2007
Author: hpk
Date: Fri Mar 2 12:00:32 2007
New Revision: 39655
Added:
py/trunk/py/misc/killproc.py (contents, props changed)
py/trunk/py/misc/testing/test_oskill.py (contents, props changed)
Modified:
py/trunk/py/misc/conftest-socketgatewayrun.py
Log:
add a (somewhat clunky) way to kill processes by PID both on windows
and unix-ish systems.
Modified: py/trunk/py/misc/conftest-socketgatewayrun.py
==============================================================================
--- py/trunk/py/misc/conftest-socketgatewayrun.py (original)
+++ py/trunk/py/misc/conftest-socketgatewayrun.py Fri Mar 2 12:00:32 2007
@@ -28,8 +28,8 @@
return True
class MySession(RemoteTerminalSession):
- socketserveradr = ('10.9.4.148', 8888)
socketserveradr = ('10.9.2.62', 8888)
+ socketserveradr = ('10.9.4.148', 8888)
def _initslavegateway(self):
print "MASTER: initializing remote socket gateway"
@@ -59,3 +59,5 @@
assert remotepypath.startswith(topdir), (remotepypath, topdir)
#print "remote side has rsynced pythonpath ready: %r" %(topdir,)
return gw, topdir
+
+dist_hosts = ['localhost', 'cobra', 'cobra']
Added: py/trunk/py/misc/killproc.py
==============================================================================
--- (empty file)
+++ py/trunk/py/misc/killproc.py Fri Mar 2 12:00:32 2007
@@ -0,0 +1,10 @@
+
+import py
+import os, sys
+
+def killproc(pid):
+ if sys.platform == "win32":
+ py.process.cmdexec("taskkill /F /PID %d" %(pid,))
+ else:
+ os.kill(pid, 15)
+
Added: py/trunk/py/misc/testing/test_oskill.py
==============================================================================
--- (empty file)
+++ py/trunk/py/misc/testing/test_oskill.py Fri Mar 2 12:00:32 2007
@@ -0,0 +1,15 @@
+
+import py, sys
+
+from py.__.misc.killproc import killproc
+
+def test_win_killsubprocess():
+ tmp = py.test.ensuretemp("test_win_killsubprocess")
+ t = tmp.join("t.py")
+ t.write("import time ; time.sleep(100)")
+ proc = py.std.subprocess.Popen([sys.executable, str(t)])
+ assert proc.poll() is None # no return value yet
+ killproc(proc.pid)
+ ret = proc.wait()
+ assert ret != 0
+
More information about the py-svn
mailing list