summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-10-28 14:20:01 +0000
committerAlan Conway <aconway@apache.org>2010-10-28 14:20:01 +0000
commit5d4cc8ea1391e5836304ca48ec761a90b63f0d84 (patch)
tree38a70b7c4cfc3559c190b7b0524f0108361065b0
parent3fee018a93fa608d12cdcb3ae7c65204140cf723 (diff)
downloadqpid-python-5d4cc8ea1391e5836304ca48ec761a90b63f0d84.tar.gz
Fix qpid/python/qpid/brokertest.py to get cluster tests working.
Fixing issues introduced by r1028156. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1028308 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/python/qpid/brokertest.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/qpid/python/qpid/brokertest.py b/qpid/python/qpid/brokertest.py
index ab779fe8d2..165d2d3811 100644
--- a/qpid/python/qpid/brokertest.py
+++ b/qpid/python/qpid/brokertest.py
@@ -21,7 +21,7 @@
# or federation
import os, signal, string, tempfile, subprocess, socket, threading, time, imp, re
-import qpid, traceback
+import qpid, traceback, signal
from qpid import connection, messaging, util
from qpid.compat import format_exc
from qpid.harness import Skipped
@@ -153,7 +153,7 @@ class Popen(subprocess.Popen):
self.cmd = [ str(x) for x in cmd ]
self.returncode = None
self.expect = expect
- subprocess.Popen.__init__(self, self.cmd, 0, None, subprocess.PIPE, subprocess.PIPE, subprocess.PIPE)
+ subprocess.Popen.__init__(self, self.cmd, 0, None, subprocess.PIPE, subprocess.PIPE, subprocess.PIPE, close_fds=True)
self.pname = "%s-%d" % (os.path.split(self.cmd[0])[1], self.pid)
msg = "Process %s" % self.pname
self.stdin = ExceptionWrapper(self.stdin, msg)
@@ -195,18 +195,7 @@ class Popen(subprocess.Popen):
except: pass
elif self.expect == EXPECT_RUNNING:
try:
- self.terminate()
- except AttributeError:
- # no terminate method to Popen..
- try:
- import signal
- os.kill( self.pid , signal.SIGTERM)
- except AttributeError:
- # no os.kill, using taskkill.. (Windows only)
- try:
- os.popen('TASKKILL /PID ' +str(self.pid) + ' /F')
- except:
- print " ERROR: could not terminate process."
+ self.kill()
except:
self.unexpected("expected running, exit code %d" % self.wait())
else:
@@ -237,7 +226,7 @@ class Popen(subprocess.Popen):
def poll(self):
if self.returncode is None:
- ret = subprocess.poll(self)
+ ret = subprocess.Popen.poll(self)
if (ret != -1):
self.returncode = ret
self._cleanup()
@@ -251,12 +240,21 @@ class Popen(subprocess.Popen):
self._cleanup()
return self.returncode
- def send_signal(self, sig):
- try: os.kill(self.pid,sig)
- except OSError,e: raise OSError("Kill failed %s: %s"%(self.pname, e))
-
- def terminate(self): self.send_signal(signal.SIGTERM)
- def kill(self): self.send_signal(signal.SIGKILL)
+ def terminate(self):
+ try: subprocess.Popen.terminate(self)
+ except AttributeError: # No terminate method
+ try:
+ os.kill( self.pid , signal.SIGTERM)
+ except AttributeError: # no os.kill, using taskkill.. (Windows only)
+ os.popen('TASKKILL /PID ' +str(self.pid) + ' /F')
+
+ def kill(self):
+ try: subprocess.Popen.kill(self)
+ except AttributeError: # No terminate method
+ try:
+ os.kill( self.pid , signal.SIGKILL)
+ except AttributeError: # no os.kill, using taskkill.. (Windows only)
+ os.popen('TASKKILL /PID ' +str(self.pid) + ' /F')
def cmd_str(self): return " ".join([str(s) for s in self.cmd])