[Freeswitch-users] mod_python sqlalchemy core dumps

. joes.mailing.lists at gmail.com
Tue Nov 11 19:44:11 PST 2008

  I've been having some frustrations with mod_python lately.  I've
stripped down the script I've been using to the barest of bare bones,
and am still getting core dumps; so I've decided to share it in the
hopes that someone else will be able to see where I've gone wrong.

  The stripped down script below does nothing more than answer, lookup
a caller based on their caller_id_number and then play back some
audio.  I'm pretty certain that the issue is with sqlalchemy, but I'm
still not clear as to why sqlalchemy should cause freeswitch to dump
core and die.
  The database model I'm using with sqlalchemy is also quite simple,
and has worked fine for almost a year with a corresponding pylons
application, so I'm fairly confident that the model itself is not the
underlying problem.  My best guess thus far is that sqlalchemy is
somehow tripping up mod_python and then freeswitch with the way it
attempts to maintain connections/state across calls?

  In any case my setup is as follows:
Python Version: 2.4.4
sqlalchemy v0.5.0rc2
freeswitch (1.0.1) [from changelog, compiled from src]
Debian 4.0 etch

  The script I'm running (trying to run right now):
# -*- mode: python; coding: utf-8 -*-
import os, re, sys
from freeswitch import *
from datetime import datetime
from time import strftime, gmtime
from loadmodel import model
consoleLog("info", "Current Python Version: %s\n\n" % str(sys.version))

def hangup_hook( session, what, caller_id ):
           Default hangup hook.  Overload as needed.
        consoleLog("info","The application hung up for %s.\n\n" % what)

def input_callback(session, what, obj, arg):
           Default input callback for dtmf and other events.  Overload
this as needed.
        if (what == "dtmf"):
                consoleLog("info", what + " " + obj.digit + "\n")
                        return arg[obj.digit]
                        return None # will make the streamfile audio stop
                consoleLog("info", what + " " + obj.serialize() + "\n")
        return "pause"

def get_current_caller( session ):
            Dig up the current caller in the database.
            if the caller isn't registered return null.
        current_caller =
        if current_caller==None:
                current_caller =
        return current_caller

class dummy_caller:
        def __init__(self, user_id="0", phone="123456789"):
                self.user_id = user_id
                self.phone = phone

def handler( session, args ):
        session.answer( )
        playback_dtmf  =
        recording_dtmf = {"2":"stop","3":"stop","5":"stop","6":"stop"}
        guidance_dtmf  = {"3":"stop","4":"stop","9":"stop"} #3 upload,
4 replay, 9 re-record
        session.setVariable( "intro",
"/usr/local/freeswitch/sounds/ja/test/test_intro_padded.wav" )
        session.setVariable( "guidance",
"/usr/local/freeswitch/sounds/ja/test/test_annai_padded.wav" )
        session.setVariable( "goodbye",
"/usr/local/freeswitch/sounds/ja/test/test_thanks_padded.wav" )
        session.setVariable( "beep",
"/usr/local/freeswitch/sounds/beeps/beep_fm.wav" )
        current_caller = get_current_caller( session )
        session.setHangupHook( hangup_hook, str(current_caller.user_id) )
        session.streamFile( session.getVariable("intro") )
        #make_recording( session, recording_dtmf,
session.getVariable("intro"), process=True )
        session.streamFile( session.getVariable("goodbye") )
        session.hangup( )


After 2 or sometimes 3 calls this inevitably causes the following crash:
2008-11-12 12:40:08 [NOTICE] switch_channel.c:538
switch_channel_set_name() New Channel
sofia/external/+818053753079 at voxbone.com
2008-11-12 12:40:08 [INFO] mod_dialplan_xml.c:228 dialplan_hunt()
Processing +XXXXXXXX->9993 in context default
Segmentation fault (core dumped)

I've spent hours hunting through related lists: mod_python (for
apache), sqlalchemy, etc. but all to no avail.  Any suggestions or
alternatives ( I've also started looking into outbound event socket,
but there still seems to be few people using this with python/twisted
) will be greatly appreciated.  If all else fails I can probably
switch to perl or js but I'd much prefer to stick to python if there
is a workable solution ( or -hopefully- if I've just missed something
very obvious ).


More information about the FreeSWITCH-users mailing list