Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] mod_python objects and session cleanup


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
joes.mailing.lists at ...
Guest





PostPosted: Sat Sep 13, 2008 10:33 pm    Post subject: [Freeswitch-users] mod_python objects and session cleanup Reply with quote

Hi,
I've been playing around a bit with mod_python and have a question
about using objects and session cleanup. I put together a trivial
object-based IVR after taking a look at some of the wikipbx examples:
http://fisheye.freeswitch.org:8081/browse/~raw,r=27/WikiPBX/ivr/baseivr.py

these seem to be based on an older version of mod_python where
PySession and uuid still represented appropriate usage, but with a
couple of minor changes I put something together that seemed
appropriate:

--------------------------------------
# -*- mode: python; coding: utf-8 -*-
from freeswitch import *

class BaseIVR( object ):
"""
Basic IVR object.
Defines some common functions and methods.
"""
def __init__( self, session ):
self.session = session
self.session.setInputCallback( self.input_callback )
self.session.setHangupHook( self.hangup_hook )

def hangup_hook( self, session, what ):
"""
Default hangup hook. Overload as needed.
"""
consoleLog( "info","The application hung up for %s.\n\n" % what )
del self.session #Without this call the session/channel never
gets cleaned-up
return

def input_callback( self, session, what, obj ):
"""
Default input callback for dtmf and other events. Overload
this as needed.
"""
if ( what == "dtmf" ):
consoleLog( "info", what + " " + obj.digit + "\n" )
else:
consoleLog( "info", what + " " + obj.serialize() + "\n" )
return "pause"

def main( self ):
"""Basic main method."""
self.session.answer( )
consoleLog( "info", "Testing my IVR object.\n\n" )
self.session.hangup( )
return

def handler( session, args ):
"""Handle the call."""
basicIVR = BaseIVR( session )
basicIVR.main( )
--------------------------------------

The above script works fine, but I noticed that, if I remove the
call to 'del self.session' which I added to the hangup_hook after
reading,
http://jira.freeswitch.org/browse/MODLANG-33

that the session will not be deleted and, as mentioned in the post
above, calling
freeswitchconsole$ show channels

will show that there are hanging/open channels.

Is this because I've created an inappropriate usage scenario, or is
this a bug?

Is the 'del self.session' an appropriate work-around or is that
likely to cause further problems down the road?


Cheers,
Joe

_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services