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.