[asterisk-commits] mjordan: testsuite/asterisk/trunk r3976 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Aug 3 14:31:22 CDT 2013


Author: mjordan
Date: Sat Aug  3 14:31:19 2013
New Revision: 3976

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3976
Log:
Allow the Hangup Channel pluggable module to delay the hangup based on config

This adds a 'delay' parameter which, if present, will delay the hanging up of
the specified channel. In general, this is useful when you've identified the
channel you want to hang up, but you want to let Asterisk reach a more
quiescant state in order to have deterministic output.

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

Modified: asterisk/trunk/lib/python/asterisk/PluggableModules.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/PluggableModules.py?view=diff&rev=3976&r1=3975&r2=3976
==============================================================================
--- asterisk/trunk/lib/python/asterisk/PluggableModules.py (original)
+++ asterisk/trunk/lib/python/asterisk/PluggableModules.py Sat Aug  3 14:31:19 2013
@@ -12,6 +12,7 @@
 
 sys.path.append("lib/python")
 from ami import AMIEventInstance
+from twisted.internet import reactor
 
 LOGGER = logging.getLogger(__name__)
 
@@ -135,6 +136,7 @@
         ''' Constructor for pluggable modules '''
         super(AMIChannelHangup, self).__init__(instance_config, test_object)
         self.hungup_channel = False
+        self.delay = instance_config.get('delay') or 0
 
     def event_callback(self, ami, event):
         ''' Override of the event callback '''
@@ -144,7 +146,7 @@
             return
         LOGGER.info('Hanging up channel %s' % event['channel'])
         self.hungup_channel = True
-        ami.hangup(event['channel'])
+        reactor.callLater(self.delay, ami.hangup, event['channel'])
 
 
 class AMIChannelHangupAll(AMIEventInstance):




More information about the asterisk-commits mailing list