[Freeswitch-users] FreeSwitch dies when calling sys.exit() from hangupHook function in Python.

Marc Orenberg marc at kasteris.com
Sun Aug 24 19:21:00 PDT 2008


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20080824/bf53ba78/attachment-0002.html 


More information about the FreeSWITCH-users mailing list