[SR-Users] [sr-dev] enabling app_python module in Kamailio

Daniel-Constantin Mierla miconda at gmail.com
Tue Nov 1 23:11:17 CET 2011


Hello,

what is the kamailio version you are running? At some point there was an 
issue with path to the python script due to changes done to it by some C 
functions. Should be fixed in latest 3.1 and 3.2 branches anyhow, but 
let's see what you use so we don't hunt solved cases.

Cheers,
Daniel

On 10/12/11 12:40 PM, Muhammad Nasir Bhutta wrote:
> Hi,
>
> Here is some more information on the error, I have tried to print all the processing steps..
>
> DEBUG: init_mod: app_python
>   0(10480) ERROR: app_python [python_mod.c:102]: lengths of different names  script_name = 34, mod_init_fname = 8, child_init_mname 10
>   0(10480) ERROR: app_python [python_mod.c:109]: tname = /usr/local/etc/kamailio/handler.py
>   0(10480) ERROR: app_python [python_mod.c:111]: dname = /usr/local/etc/kamailio
>   0(10480) ERROR: app_python [python_mod.c:116]: base name = handler.py
>   0(10480) ERROR: app_python [python_mod.c:128]: base name after being processed for .py extension = handler
>   0(10480) ERROR: app_python [python_mod.c:134]: python is initialized and thread state is stored
>   0(10480) ERROR: app_python [python_mod.c:143]: Router module is initialized successfully
>   0(10480) ERROR: app_python [python_mod.c:152]: System Object path is successfully imported
>   0(10480) ERROR: app_python [python_mod.c:160]: directory is successfully loaded in object
>   0(10480) ERROR: app_python [python_mod.c:164]: directory and system path is inserted in Python list
>   0(10480) ERROR: app_python [python_mod.c:168]: cannot import handler
>   0(10480) ERROR:<core>  [sr_module.c:889]: init_mod(): Error while initializing module app_python (/usr/local/lib64/kamailio/modules/app_python.so)
> ERROR: error while initializing modules
>
> If any one can please help, that shall be great..
>
> Regards,
> Nasir
> -----Original Message-----
> From: Muhammad Nasir Bhutta
> Sent: 12 October 2011 11:17
> To: 'Timo Reimann'; Development mailing list of the sip-router project
> Cc: sr-users at lists.sip-router.org; Tim Couper
> Subject: RE: [sr-dev] enabling app_python module in Kamailio
>
> Hi Timo,
> Yes, I have investigated it a bit more. The problem is not that warning it is an error which stops the Kamailio to start..
> The error is
> "0(25062) DEBUG:<core>  [sr_module.c:885]: DEBUG: init_mod: app_python
>   0(25062) ERROR: app_python [python_mod.c:158]: cannot import handler
>   0(25062) ERROR:<core>  [sr_module.c:889]: init_mod(): Error while initializing module app_python (/usr/local/lib64/kamailio/modules/app_python.so)
> ERROR: error while initializing modules"
>
> I have tried to investigate a bit more, and the problem is that it is not able to find the handler.py file..
> The error is occurring in init_mod() function which is trying to call a function called "PyImport_ImportModule(bname)" function..  The file tries to set the absolute path in the start .. The absolute path was setup with reference to "sip-router" folder which is old.. So, I changed the path to Kamailio folder..  But, the module can't be loaded...
>
> To investigate this loading problem, I have seen the functions being called. PyImport_ImportModule takes the name of module to load..  if "." is used that specifies the sub modules..so, this function is being passed just the word "handler"..  The absolute path in the start is setup for a file called "handler.py".. This file is trying to push the directory path in the path as well, but I think maybe there is some problem lying.. I tried to load by passing full path name to PyImport_ImportModule() as well but, in vain..
>
> Hope this clarifies things more..
>
> Regards,
> Nasir
>
> -----Original Message-----
> From: Timo Reimann [mailto:timo.reimann at 1und1.de]
> Sent: 12 October 2011 10:38
> To: Development mailing list of the sip-router project
> Cc: Muhammad Nasir Bhutta; sr-users at lists.sip-router.org; Tim Couper
> Subject: Re: [sr-dev] enabling app_python module in Kamailio
>
> On 11.10.2011 15:08, Muhammad Nasir Bhutta wrote:
>> I am trying to enable the app_python module in Kamailio to run a
>> simple python script externally parallel with Kamailio proxy,
>>
>>
>>
>> While I try to load the module "app_python.so" in configuration file,
>> the Kamailio server fails to start.. I can't see what is the problem ..
>>
>>
>>
>> The steps, I am following are that:
>>
>>
>>
>> -          Script written in python saved in home directory.
>>
>> -          Loadmodule "app_python.so" statement in configuration file.
>>
>> -          Modparam("app_python", "script_name", "location of script")
>>
>> -          Python_exec("function", "parameters list") ..
>>
>>
>>
>> I have also tried to check the Kamailio configuration option, It gives
>> following warning,
>>
>> 0(2942) WARNING:<core>  [sr_module.c:584]:
>> /usr/local/lib64/kamailio/modules/app_python.so: exports dlflags
>> interface is deprecated and it will not be supported in newer
>> versions; consider using mod_register() instead
> Is there no other error message? What you provided is just a WARNING which shouldn't be a show stopper.
>
>
> --Timo
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list