`KSR.tm.t_relay()` is returning int. The sample config has it like `if KSR.tm.t_relay() < 0:`, but I guess it should work evaluating an int anyhow in the if condition of python. Does it happen every time the script is executed? Do you get any other error messages before those pasted above, from the start of kamailio?