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

Anthony Minessale anthony.minessale at gmail.com
Mon Aug 25 07:37:36 PDT 2008


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 at kasteris.com> wrote:

> 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 at 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 at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
iax:guest at conference.freeswitch.org/888
googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
pstn:213-799-1400
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20080825/7fbf114e/attachment-0002.html 


More information about the FreeSWITCH-users mailing list