Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

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

[Freeswitch-users] FreeSwitch dies when calling sys.exit() f


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





PostPosted: Sun Aug 24, 2008 9:24 pm    Post subject: [Freeswitch-users] FreeSwitch dies when calling sys.exit() f Reply with quote

When I use the Python function sys.exit() in the hangup callback function, it immediately causes the FreeSwitch application to stop running. But I need to somehow stop the Python script from running in this situation.

Here is a simple example:

def hangup_hook(session, what):
print("info","Hangup hook for %s!!\n\n" % what)
sys.exit()

def handler(session, args):
session.answer()
session.setHangupHook(hangup_hook)
while(1):
session.streamFile(PROMPTS_DIR + "ThanksForCalling.wav")

The above script simply plays "Thanks for calling" over and over. If I hang-up, FreeSwitch dies. If I remove the sys.exit(), it will return from hangup_hook and continue trying to play the prompt forever.

Thanks for your help.
Back to top
anthony.minessale at g...
Guest





PostPosted: Mon Aug 25, 2008 9:44 am    Post subject: [Freeswitch-users] FreeSwitch dies when calling sys.exit() f Reply with quote

never use while(1) or the system exit call from your script.

replace while(1) with while(session.ready())



On Sun, Aug 24, 2008 at 9:21 PM, Marc Orenberg <marc@kasteris.com (marc@kasteris.com)> wrote:
Quote:
When I use the Python function sys.exit() in the hangup callback function, it immediately causes the FreeSwitch application to stop running. But I need to somehow stop the Python script from running in this situation.

Here is a simple example:

def hangup_hook(session, what):
print("info","Hangup hook for %s!!\n\n" % what)
sys.exit()

def handler(session, args):
session.answer()
session.setHangupHook(hangup_hook)
while(1):
session.streamFile(PROMPTS_DIR + "ThanksForCalling.wav")

The above script simply plays "Thanks for calling" over and over. If I hang-up, FreeSwitch dies. If I remove the sys.exit(), it will return from hangup_hook and continue trying to play the prompt forever.

Thanks for your help.





_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org (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




--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
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