Hello,
then you do not use the KEMI framework as config interpreter, but native
configuration interpreter with inline execution of Python code via
python_exec(). KSR module is exported for both cases, KEMI or inline
execution, but KSR.x.exit() (or python exit) stops the KEMI execution,
not the native config execution.
A way to signal that you want to exit native config execution after
python_exec() is to use some local variable, like:
$var(exit) = 0;
python_exec(...);
if($var(exit) == 1) exit;
And inside the python script you execute with python_exec() set
$var(exit) to 1 via KSR.pv_seti(...) whenever you want to do an exit.
Otherwise, I haven't developed python_exec() to see what exactly it does
and if it propagates return 0 from python script to kamailio native
interpreter -- return code 0 is used to signal a stop of config
execution, done from a sub-route or a c function:
*
https://www.kamailio.org/wiki/cookbooks/devel/core#return
Cheers,
Daniel
On 29.03.18 10:13, Enrico Bandiera wrote:
Hi Daniel,
it seems that your suggestion is not working, we are not using python
for the whole script, we have some functions written in python to
manipulate jsons and to do API queries which we keep in python but the
core of the routing logic is still written in Kamailio scripting language.
We call the python functions with python_exec()
I tried to use both exit() and os.exit() but it looks like they are
ignored and the route execution continues, the only thing that seems
to work is to return 0 from the function
Can you tell me please if it is safe to use the return value to exit?
Thanks,
Enrico.
2018-03-28 16:35 GMT+02:00 Daniel-Constantin Mierla <miconda(a)gmail.com
<mailto:miconda@gmail.com>>:
Hello,
in Python you can call exit() or os.exit(), this throws an
exception which is caught by Kamailio and interpreted as the usual
exit from kamailio.cfg.
Probably we should add the KSR.x.exit() there as well, it was not
added because python exit gave what was needed in this case
Cheers,
Daniel
On 27.03.18 16:49, Enrico Bandiera wrote:
Hello, I'm trying to use the KSR.x.exit()
function in a KEMI
python script but at runtime i get this error:
KSR.x.exit()
AttributeError: 'module' object has no attribute 'exit'
It seems that the exit function is missing even though it is
documented.
My kamailio version is: kamailio 5.2.0-dev4 (x86_64/linux) (it's
a nightly)
Any idea on what I can do?
Thanks,
Enrico.
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
<https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
--
Daniel-Constantin Mierla
www.twitter.com/miconda <http://www.twitter.com/miconda> --
www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
Kamailio Advanced Training - April 16-18, 2018, Berlin -
www.asipto.com
<http://www.asipto.com>
Kamailio World Conference - May 14-16, 2018 -
www.kamailioworld.com
<http://www.kamailioworld.com>
--
Daniel-Constantin Mierla
www.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio Advanced Training - April 16-18, 2018, Berlin -
www.asipto.com
Kamailio World Conference - May 14-16, 2018 -
www.kamailioworld.com