Hi Richard,

Thanks for the tip, I had indeed overlooked the return value.

Cheers
Matthew

On Tue, 5 Mar 2024 at 05:34, Richard Chan <shihping.chan@gmail.com> wrote:
In the method can you put

return 1

at the end. KEMI python is very strict on an int return value.

On Tue, 5 Mar 2024, 07:08 Marrold via sr-users, <sr-users@lists.kamailio.org> wrote:
Hi all,

I am using Kamailio 5.7.4 on a Debian 12 machine, with a Python Kemi based config. I am seeing some intermittent failures when accessing an instance variable within a function called by rtimer.

I'm using the rtimer module with the following parameters:

modparam("rtimer", "timer", "name=hello;interval=5;mode=0;")
modparam("rtimer", "exec", "timer=hello;route=ksr_route_hello")

I initialise the kamailio class, and instance variable like this:

class kamailio:
    def __init__(self):

        self.hello = "hi"

Within the class I have the following route  function:

    def ksr_route_hello(self, msg, evname):

        KSR.info("Running ksr_route_hello\n")
        KSR.info(f"Hello? {self.hello}\n")

Then in the logs I see it sometimes works, and sometimes fails:

 9(15) INFO: <core> [core/kemi.c:106]: sr_kemi_core_info(): Running ksr_route_hello
 9(15) INFO: <core> [core/kemi.c:106]: sr_kemi_core_info(): Hello? hi

 9(15) INFO: <core> [core/kemi.c:106]: sr_kemi_core_info(): Running ksr_route_hello
 9(15) ERROR: app_python3 [python_support.c:167]: python_handle_exception(): apy_exec: ksr_route_hello(rtimer): Unhandled exception in the Python code:
TypeError: 'NoneType' object cannot be interpreted as an integer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/etc/kamailio/kamailio.py", line 1007, in ksr_route_hello
    KSR.info("Running ksr_route_hello\n")
SystemError: <built-in function info> returned a result with an exception set

Does anyone know where I'm going wrong?

Thanks
Matthew
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe: