[svn r39655] add a (somewhat clunky) way to kill processes by PID both on windows

and unix-ish systems.

--HG--
branch : trunk
This commit is contained in:
hpk 2007-03-02 12:00:32 +01:00
parent 2cd886f442
commit 40b28ca0fe
3 changed files with 28 additions and 1 deletions

View File

@ -28,8 +28,8 @@ class MyRSync(py.execnet.RSync):
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 @@ class MySession(RemoteTerminalSession):
assert remotepypath.startswith(topdir), (remotepypath, topdir)
#print "remote side has rsynced pythonpath ready: %r" %(topdir,)
return gw, topdir
dist_hosts = ['localhost', 'cobra', 'cobra']

10
py/misc/killproc.py Normal file
View File

@ -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)

View File

@ -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