[asterisk-commits] coreyfarrell: testsuite/asterisk/trunk r5818 - /asterisk/trunk/lib/python/ast...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 30 18:49:36 CDT 2014


Author: coreyfarrell
Date: Thu Oct 30 18:49:32 2014
New Revision: 5818

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5818
Log:
Close ARI websocket connections before stopping reactor.

All (or most) tests in tests/rest_api leak numerous referenced
objects by not closing the ARI websocket connection.  This adds
a hook to stop_reactor that closes the websocket connection.

Review: https://reviewboard.asterisk.org/r/4121/

Modified:
    asterisk/trunk/lib/python/asterisk/ari.py

Modified: asterisk/trunk/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ari.py?view=diff&rev=5818&r1=5817&r2=5818
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ari.py (original)
+++ asterisk/trunk/lib/python/asterisk/ari.py Thu Oct 30 18:49:32 2014
@@ -70,6 +70,7 @@
         self.ari_factory = AriClientFactory(receiver=self, host=host, port=port,
                                             apps=self.apps, userpass=userpass)
 
+        self._ws_connection = None
         self._ws_event_handlers = []
         self.timed_out = False
 
@@ -117,6 +118,7 @@
 
         :param protocol The WS Client protocol object
         """
+        self._ws_connection = protocol
         reactor.callLater(0, self._create_ami_connection)
 
     def on_ws_closed(self, protocol):
@@ -124,12 +126,17 @@
 
         :param protocol The WS Client protocol object
         """
+        self._ws_connection = None
         LOGGER.debug("WebSocket connection closed...")
 
     def _create_ami_connection(self):
         """Create the AMI connection"""
         self.create_ami_factory(count=self.asterisk_instances)
 
+    def stop_reactor(self):
+        if self._ws_connection != None:
+            self._ws_connection.dropConnection()
+        super(AriBaseTestObject, self).stop_reactor()
 
 class AriTestObject(AriBaseTestObject):
     """Class that acts as a Test Object in the pluggable module framework"""




More information about the asterisk-commits mailing list