<div dir="ltr">Dear Kamailio users,<div>I am trying to use a python script using the module app_python3 to do some billing calculations.<br><br>The only argument i want to pass to the python script is duration which i calculate in </div><div><br></div><div>event_route[dialog:start] {<br>        $dlg_var('call_start') = $TS;<br></div><div><br></div><div>event_route[dialog:end] {</div>        $var('v_duration') = $TS - $dlg_var('call_start');<div><br></div><div>So my $var('v_duration') has the duration of the call in seconds.<br><br>Then i execute from my kamailio.cfg: </div><div>python_exec("calculateCost","$var('v_duration')");<br></div><div><br></div><div>The script works randomly - sometimes all is good and sometimes it throw error : <br><br>app_python3 [python_support.c:156]: python_handle_exception(): apy_exec: calculateCost(4): Unhandled exception in the Python code:<br>                                                   TypeError: an integer is required (got type NoneType)<br><br>                                                   The above exception was the direct cause of the following exception:<br><br>                                                   Traceback (most recent call last):<br>                                                     File "/etc/kamailio/kamailio-python.py", line 282, in calculateCost<br>                                                       duration = int(duration)<br></div><div><br></div><div>It looks like the kamailio log show calculateCost(4) so argument 4 is passed to python function but once it executes it appear like there is no string/integer but NoneType argument.<br><br>I cannot figure this out why this randomly happens - maybe it's an app_python3 module issue?<br><br>Looking to hear back from you!<br><br></div><div>BR,<br>Tom<br><br></div></div>