[SR-Users] Kamailio python_exec getting randomly TypeError
Voip support
voipexpert0 at gmail.com
Tue Jul 20 00:20:01 CEST 2021
Dear Kamailio users,
I am trying to use a python script using the module app_python3 to do some
billing calculations.
The only argument i want to pass to the python script is duration which i
calculate in
event_route[dialog:start] {
$dlg_var('call_start') = $TS;
event_route[dialog:end] {
$var('v_duration') = $TS - $dlg_var('call_start');
So my $var('v_duration') has the duration of the call in seconds.
Then i execute from my kamailio.cfg:
python_exec("calculateCost","$var('v_duration')");
The script works randomly - sometimes all is good and sometimes it throw
error :
app_python3 [python_support.c:156]: python_handle_exception(): apy_exec:
calculateCost(4): Unhandled exception in the Python code:
TypeError: an integer is
required (got type NoneType)
The above exception was
the direct cause of the following exception:
Traceback (most recent
call last):
File
"/etc/kamailio/kamailio-python.py", line 282, in calculateCost
duration =
int(duration)
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.
I cannot figure this out why this randomly happens - maybe it's an
app_python3 module issue?
Looking to hear back from you!
BR,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210720/5ffca145/attachment.htm>
More information about the sr-users
mailing list