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 > [email protected] > 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 _______________________________________________ Kamailio (SER) - Users Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
