Author: gsim
Date: Wed Feb 21 10:06:02 2007
New Revision: 510128
URL: http://svn.apache.org/viewvc?view=rev&rev=510128
Log:
Ensure socket is closed in tearDown
Modified:
incubator/qpid/branches/qpid.0-9/python/qpid/client.py
incubator/qpid/branches/qpid.0-9/python/qpid/connection.py
incubator/qpid/branches/qpid.0-9/python/qpid/testlib.py
Modified: incubator/qpid/branches/qpid.0-9/python/qpid/client.py
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/python/qpid/client.py?view=diff&rev=510128&r1=510127&r2=510128
==============================================================================
--- incubator/qpid/branches/qpid.0-9/python/qpid/client.py (original)
+++ incubator/qpid/branches/qpid.0-9/python/qpid/client.py Wed Feb 21 10:06:02
2007
@@ -76,7 +76,8 @@
self.locale = locale
self.tune_params = tune_params
- self.conn = Connection(connect(self.host, self.port), self.spec)
+ self.socket = connect(self.host, self.port)
+ self.conn = Connection(self.socket, self.spec)
self.peer = Peer(self.conn, ClientDelegate(self), self.opened)
self.conn.init()
@@ -89,6 +90,9 @@
def opened(self, ch):
ch.references = References()
+
+ def close(self):
+ self.socket.close()
class ClientDelegate(Delegate):
Modified: incubator/qpid/branches/qpid.0-9/python/qpid/connection.py
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/python/qpid/connection.py?view=diff&rev=510128&r1=510127&r2=510128
==============================================================================
--- incubator/qpid/branches/qpid.0-9/python/qpid/connection.py (original)
+++ incubator/qpid/branches/qpid.0-9/python/qpid/connection.py Wed Feb 21
10:06:02 2007
@@ -53,6 +53,9 @@
def flush(self):
pass
+ def close(self):
+ self.sock.shutdown(socket.SHUT_RDWR)
+
def connect(host, port):
sock = socket.socket()
sock.connect((host, port))
Modified: incubator/qpid/branches/qpid.0-9/python/qpid/testlib.py
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/python/qpid/testlib.py?view=diff&rev=510128&r1=510127&r2=510128
==============================================================================
--- incubator/qpid/branches/qpid.0-9/python/qpid/testlib.py (original)
+++ incubator/qpid/branches/qpid.0-9/python/qpid/testlib.py Wed Feb 21 10:06:02
2007
@@ -122,7 +122,11 @@
self._parseargs(args)
runner = unittest.TextTestRunner(descriptions=False,
verbosity=self.verbose)
- result = runner.run(self.testSuite())
+ try:
+ result = runner.run(self.testSuite())
+ except:
+ print "Unhandled error in test:", sys.exc_info()
+
if (self.ignore):
print "======================================="
print "NOTE: the following tests were ignored:"
@@ -167,14 +171,18 @@
self.channel.channel_open()
def tearDown(self):
- for ch, q in self.queues:
- ch.queue_delete(queue=q)
- for ch, ex in self.exchanges:
- ch.exchange_delete(exchange=ex)
+ try:
+ for ch, q in self.queues:
+ ch.queue_delete(queue=q)
+ for ch, ex in self.exchanges:
+ ch.exchange_delete(exchange=ex)
+ except:
+ print "Error on tearDown:", sys.exc_info()
if not self.client.closed:
self.client.channel(0).connection_close(reply_code=200)
- del self.client
+ else:
+ self.client.close()
def connect(self, *args, **keys):
"""Create a new connction, return the Client object"""