[SR-Users] python_exec return 0 causes script hangs; return -1 is treated like 0
Daniel-Constantin Mierla
miconda at gmail.com
Thu Feb 15 11:37:53 CET 2018
Hello,
kamailio's native scripting language interpreter has a custom handling
for return values:
- return < 0 - it is evaluated as false
- return >0 - it is evaluated as true
- return = 0 - it is evaluated as 'stop execution of config script'
See also:
-
https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_cod
It is how the interpreter was designed long time ago (like 2001 - 2002).
Cheers,
Daniel
On 15.02.18 10:28, Anthony Alba wrote:
> 5.1.1: if python_exec method returns 0, then the script hangs
>
> If the python_exec method return -1, then expressions treat it as if
> it returned zero.
>
> Somewhere there seems to be an offset by 1 issue.
>
> if (!python_exec("method")) {
> # if you return -1, the script does not hang but treated like zero
> }
>
> ##################
> Example 1:
> class kamailio(object):
> def hello(self, msg):
> KSR.info("hello, world\n")
> return 0
>
> Calling: python_exec("hello")
>
> will cause script hang
>
> ###################
> Example 2:
> class kamailio(object):
> def hello(self, msg):
> KSR.info("hello, world\n")
> return -1
>
> Calling python_exec("hello")
>
> if (!python_exec("hello")) {
> ## method returns -1
> ## why did we get here?
> xlog("L_INFO","method return zero!\n");
> }
>
>
> shows INFO: <script>: method return zero!
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - March 5-7, 2018, Berlin - www.asipto.com
Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com
More information about the sr-users
mailing list