[SR-Users] KEMI routing script Python exceptions with empty traceback

Michael Loughrey mgloughrey at gmail.com
Mon Jun 18 18:05:34 CEST 2018


Hi All,

I'm using app_python with a KEMI Python routing script. I have been getting
occasional Python exception error logs :


kamailio[2242]:  8(2253) ERROR: app_python [python_support.c:150]:
python_handle_exception(): python_exec2: Unhandled exception in the Python
code:
kamailio[2242]: TypeError: an integer is required

The scripts seems to function without an issue but these error logs appear
fairly frequently, always with an empty Python stack trace.

I am running Kamailio 5.1 on a Debian 9 system and using Python 2.7 :

>>:/usr/local/etc/kamailio# python --version
Python 2.7.13

>>:/usr/local/etc/kamailio# kamailio -v
version: kamailio 5.1.4 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE,
USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC,
TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT,
USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST,
HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled on 18:56:43 Jun  8 2018 with gcc 6.3.0


I have also tried using a Kamailio load built from the master branch
(commit f8b8cecb) which gives enhanced exception logging identifying the
function an exception occurs within and parameters. I see this occurring in
different parts of the routing script e.g.

from script

    def ksr_onsend_route(self,msg):
        KSR.xlog.xdbg("ONSEND_ROUTE fs=[$fs] $mb\n");
        return 1;

an exception is reported within ksr_onsend_route() even when the log level
is info.

Changing log to xlog.xinfo, the log is seen to be sent to syslog but again
the exception is reported. These exceptions are always "TypeError: an
integer is required" but don't seem related to the Python script.

Here is an example of the log with a patch applied to to Kamailio 5.1 to
show the function the exception is reported within.


kamailio[14092]:  6(14103) ERROR: app_python [python_support.c:156]:
python_handle_exception(): apy_exec: ksr_reply_route((null)): Unhandled
exception in the Python code:
kamailio[14092]: TypeError: an integer is required
.
.
.
kamailio[14092]: 22(14119) INFO: <script>: ONSEND_ROUTE fs=[udp:
10.0.31.126:5080] ACK sip:10008 at media.test.io:5061;transport=TLS SIP/2.0
.
.
.
.
kamailio[14092]: 22(14119) ERROR: app_python [python_support.c:156]:
python_handle_exception(): apy_exec: ksr_onsend_route((null)): Unhandled
exception in the Python code:
kamailio[14092]: TypeError: an integer is required


Has anyone got an idea what can be causing these exceptions and how to
avoid them? Currently I have simply patched the load to drop the level of
this log to debug when such an exception occurs with an empty traceback as
they seem spurious.

Cheers
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20180618/87c63ae3/attachment.html>


More information about the sr-users mailing list