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