[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-users
Subject:    [SR-Users] Fatal Python error: failed releasing import lock after fork
From:       Nigel Daniels <nigel.daniels () gmail ! com>
Date:       2022-05-29 6:18:37
Message-ID: CAOikNcX+ob1WiZmSV91F0zQTW3UkxH6B3SiCOmM9NuBWA55EhA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


The logs appear as follows:

Fatal Python error: failed releasing import lock after fork


 Current thread 0x 7(13) DEBUG: <core> [core/utils/sruid.c:121]:
sruid_init(): root for sruid is [srid-62930e67-d-] (0 / 16)
kamailio             | 00007fe8fb8a4180 (most recent call first):
kamailio             | <no Python frame>
kamailio             |  7(13) DEBUG: <core> [core/sr_module.c:875]:
init_mod_child(): idx 7 rank -2: tm [ctl handler]
kamailio             |  7(13) DEBUG: tm [callid.c:136]:
child_init_callid(): callid: '06d932e436730fa0-13@10.10.0.4'
kamailio             |  7(13) DEBUG: <core> [core/sr_module.c:875]:
init_mod_child(): idx 7 rank -2: tmx [ctl handler]
kamailio             |  7(13) DEBUG: tmx [tmx_mod.c:262]: child_init():
rank is (-2)
kamailio             |  7(13) DEBUG: <core> [core/sr_module.c:875]:
init_mod_child(): idx 7 rank -2: sl [ctl handler]
kamailio             |  7(13) DEBUG: <core> [core/sr_module.c:875]:
init_mod_child(): idx 7 rank -2: ctl [ctl handler]
kamailio             |  7(13) DEBUG: <core> [core/sr_module.c:875]:
init_mod_child(): idx 7 rank -2: debugger [ctl handler]
kamailio             |  7(13) DEBUG: debugger [debugger_mod.c:224]:
child_init(): rank is (-2)
kamailio             |  7(13) DEBUG: <core> [core/sr_module.c:875]:
init_mod_child(): idx 7 rank -2: app_python3 [ctl handler]
kamailio             |  7(13) DEBUG: app_python3 [apy_kemi.c:234]:
sr_apy_kemi_exec_func_ex(): execution of method: .info
kamailio             |  7(13) DEBUG: app_python3 [apy_kemi.c:266]:
sr_apy_kemi_exec_func_ex(): param[1] for: info is str: =====
kamailio.child_init(-2)
kamailio             |
kamailio             |  7(13) INFO: <core> [core/kemi.c:106]:
sr_kemi_core_info(): ===== kamailio.child_init(-2)
kamailio             |  7(13) DEBUG: ctl [ctl.c:329]: mod_child(): ctl:
mod_child(0), fork_process=0, csl=0x556774893180
kamailio             |  7(13) DEBUG: ctl [ctl.c:336]: mod_child(): ctl: 0
io_listen_loop(1, 0x556774893180)
kamailio             |  7(13) INFO: ctl [io_listener.c:213]:
io_listen_loop(): io_listen_loop:  using epoll_lt io watch method (config)
kamailio             |  7(13) DEBUG: ctl [io_listener.c:245]:
io_listen_loop(): io_listen_loop: adding socket 8, type 2, transport 3
(/var/run/kamailio//kamailio_ctl)
kamailio             |  7(13) DEBUG: ctl [../../core/io_wait.h:374]:
io_watch_add(): processing io_watch_add(0x7fe8f9aef380, 8, 2,
0x556774893180) - fd_no=0


Running python 3.8.10

using the suggested.

# ----------------- setting module-specific parameters ---------------

# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 30sec
modparam("tm", "fr_timer", 30000)
# default invite retransmission timeout after 1xx: 120sec
modparam("tm", "fr_inv_timer", 120000)

# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)

####### Routing Logic ########

modparam("app_python3", "load", "/opt/kamailio/etc/kamailio.py")

cfgengine "python"a


import sys
import KSR as KSR


def dumpObj(obj):
    for attr in dir(obj):
        KSR.info("obj.%s = %s\n" % (attr, getattr(obj, attr)))


def mod_init():
    KSR.info("===== from Python mod init\n")
    dumpObj(KSR)
    return kamailio()


class kamailio:
    def __init__(self):
        KSR.info('===== kamailio.__init__\n')

    def child_init(self, rank):
        KSR.info('===== kamailio.child_init(%d)\n' % rank)
        return 0

    def ksr_request_route(self, msg):
        KSR.info("===== request - from kamailio python script\n")
        KSR.setdsturi("sip:alice@127.0.0.1:5080")
        KSR.tm.t_on_branch("ksr_branch_route_one")
        KSR.tm.t_on_reply("ksr_onreply_route_one")
        KSR.tm.t_on_failure("ksr_failure_route_one")
        KSR.sl.send_reply(100, "Trying")
        if KSR.tm.t_relay() < 0 :
            KSR.sl.send_reply(500, "Server error")
        return 1

    def ksr_reply_route(self, msg):
        KSR.info("===== response - from kamailio python script\n")
        return 1

    def ksr_onsend_route(self, msg):
        KSR.info("===== onsend route - from kamailio python script\n")
        return 1

    def ksr_branch_route_one(self, msg):
        KSR.info("===== branch route - from kamailio python script\n")
        return 1

    def ksr_onreply_route_one(self, msg):
        KSR.info("===== onreply route - from kamailio python script\n")
        return 1

    def ksr_failure_route_one(self, msg):
        KSR.info("===== failure route - from kamailio python script\n")
        return 1


Any help is appreciated, thanks.


-- 
- Nigel

[Attachment #5 (text/html)]

<div dir="ltr"><div>The logs appear as follows:</div><div><br></div><div>Fatal Python \
error: failed releasing import lock after \
fork</div><div><br></div><div><br></div><div>  Current thread 0x 7(13) DEBUG: \
&lt;core&gt; [core/utils/sruid.c:121]: sruid_init(): root for sruid is \
[srid-62930e67-d-] (0 / 16)<br>kamailio                   | 00007fe8fb8a4180 (most \
recent call first):<br>kamailio                   | &lt;no Python \
frame&gt;<br>kamailio                   |   7(13) DEBUG: &lt;core&gt; \
[core/sr_module.c:875]: init_mod_child(): idx 7 rank -2: tm [ctl handler]<br>kamailio \
|   7(13) DEBUG: tm [callid.c:136]: child_init_callid(): callid: &#39;<a \
href="mailto:06d932e436730fa0-13@10.10.0.4">06d932e436730fa0-13@10.10.0.4</a>&#39;<br>kamailio \
|   7(13) DEBUG: &lt;core&gt; [core/sr_module.c:875]: init_mod_child(): idx 7 rank \
-2: tmx [ctl handler]<br>kamailio                   |   7(13) DEBUG: tmx \
[tmx_mod.c:262]: child_init(): rank is (-2)<br>kamailio                   |   7(13) \
DEBUG: &lt;core&gt; [core/sr_module.c:875]: init_mod_child(): idx 7 rank -2: sl [ctl \
handler]<br>kamailio                   |   7(13) DEBUG: &lt;core&gt; \
[core/sr_module.c:875]: init_mod_child(): idx 7 rank -2: ctl [ctl \
handler]<br>kamailio                   |   7(13) DEBUG: &lt;core&gt; \
[core/sr_module.c:875]: init_mod_child(): idx 7 rank -2: debugger [ctl \
handler]<br>kamailio                   |   7(13) DEBUG: debugger \
[debugger_mod.c:224]: child_init(): rank is (-2)<br>kamailio                   |   \
7(13) DEBUG: &lt;core&gt; [core/sr_module.c:875]: init_mod_child(): idx 7 rank -2: \
app_python3 [ctl handler]<br>kamailio                   |   7(13) DEBUG: app_python3 \
[apy_kemi.c:234]: sr_apy_kemi_exec_func_ex(): execution of method: .info<br>kamailio  \
|   7(13) DEBUG: app_python3 [apy_kemi.c:266]: sr_apy_kemi_exec_func_ex(): param[1] \
for: info is str: ===== kamailio.child_init(-2)<br>kamailio                   | \
<br>kamailio                   |   7(13) INFO: &lt;core&gt; [core/kemi.c:106]: \
sr_kemi_core_info(): ===== kamailio.child_init(-2)<br>kamailio                   |   \
7(13) DEBUG: ctl [ctl.c:329]: mod_child(): ctl: mod_child(0), fork_process=0, \
csl=0x556774893180<br>kamailio                   |   7(13) DEBUG: ctl [ctl.c:336]: \
mod_child(): ctl: 0 io_listen_loop(1, 0x556774893180)<br>kamailio                   | \
7(13) INFO: ctl [io_listener.c:213]: io_listen_loop(): io_listen_loop:   using \
epoll_lt io watch method (config)<br>kamailio                   |   7(13) DEBUG: ctl \
[io_listener.c:245]: io_listen_loop(): io_listen_loop: adding socket 8, type 2, \
transport 3 (/var/run/kamailio//kamailio_ctl)<br>kamailio                   |   7(13) \
DEBUG: ctl [../../core/io_wait.h:374]: io_watch_add(): processing \
io_watch_add(0x7fe8f9aef380, 8, 2, 0x556774893180) - \
fd_no=0<br></div><div><br></div><div><br></div><div>Running python 3.8.10 \
<br></div><div><br></div><div>using the suggested.<br></div><div><pre \
style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:&quot;JetBrains \
Mono&quot;,monospace;font-size:9.8pt"><span \
style="color:rgb(128,128,128);font-style:italic"># ----------------- setting \
module-specific parameters ---------------<br></span><span \
style="color:rgb(128,128,128);font-style:italic"><br></span><span \
style="color:rgb(128,128,128);font-style:italic"># ----- tm params \
-----<br></span><span style="color:rgb(128,128,128);font-style:italic"># auto-discard \
branches from previous serial forking leg<br></span>modparam(<span \
style="color:rgb(106,135,89)">&quot;tm&quot;</span>, <span \
style="color:rgb(106,135,89)">&quot;failure_reply_mode&quot;</span>, 3)<br><span \
style="color:rgb(128,128,128);font-style:italic"># default retransmission timeout: \
30sec<br></span>modparam(<span style="color:rgb(106,135,89)">&quot;tm&quot;</span>, \
<span style="color:rgb(106,135,89)">&quot;fr_timer&quot;</span>, 30000)<br><span \
style="color:rgb(128,128,128);font-style:italic"># default invite retransmission \
timeout after 1xx: 120sec<br></span>modparam(<span \
style="color:rgb(106,135,89)">&quot;tm&quot;</span>, <span \
style="color:rgb(106,135,89)">&quot;fr_inv_timer&quot;</span>, 120000)<br><br><span \
style="color:rgb(128,128,128);font-style:italic"># ----- debugger params \
-----<br></span>modparam(<span \
style="color:rgb(106,135,89)">&quot;debugger&quot;</span>, <span \
style="color:rgb(106,135,89)">&quot;cfgtrace&quot;</span>, 1)<br><br><span \
style="color:rgb(128,128,128);font-style:italic">####### Routing Logic \
########<br></span><span \
style="color:rgb(128,128,128);font-style:italic"><br></span>modparam(<span \
style="color:rgb(106,135,89)">&quot;app_python3&quot;</span>, <span \
style="color:rgb(106,135,89)">&quot;load&quot;</span>, <span \
style="color:rgb(106,135,89)">&quot;/opt/kamailio/etc/kamailio.py&quot;</span>)<br><br>cfgengine \
<span style="color:rgb(106,135,89)">&quot;python&quot;a</span></pre></div><div><div><br></div><div><pre \
style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:&quot;JetBrains \
Mono&quot;,monospace;font-size:9.8pt"><span style="color:rgb(204,120,50)">import \
</span>sys<br><span style="color:rgb(204,120,50)">import </span>KSR <span \
style="color:rgb(204,120,50)">as </span>KSR<br><br><br><span \
style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">dumpObj</span>(obj):<br>    <span \
style="color:rgb(204,120,50)">for </span>attr <span style="color:rgb(204,120,50)">in \
</span><span style="color:rgb(136,136,198)">dir</span>(obj):<br>        \
KSR.info(<span style="color:rgb(106,135,89)">&quot;obj.%s = %s</span><span \
style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">&quot; \
</span>% (attr<span style="color:rgb(204,120,50)">, </span><span \
style="color:rgb(136,136,198)">getattr</span>(obj<span \
style="color:rgb(204,120,50)">, </span>attr)))<br><br><br><span \
style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">mod_init</span>():<br>    KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== from Python mod init</span><span \
style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>    dumpObj(KSR)<br>    <span \
style="color:rgb(204,120,50)">return </span>kamailio()<br><br><br><span \
style="color:rgb(204,120,50)">class </span>kamailio:<br>    <span \
style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(178,0,178)">__init__</span>(<span \
style="color:rgb(148,85,141)">self</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&#39;===== kamailio.__init__</span><span \
style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&#39;</span>)<br><br>    <span \
style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">child_init</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span>rank):<br>        KSR.info(<span style="color:rgb(106,135,89)">&#39;===== \
kamailio.child_init(%d)</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&#39; </span>% rank)<br>        <span \
style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">0<br></span><span \
style="color:rgb(104,151,187)"><br></span><span style="color:rgb(104,151,187)">    \
</span><span style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">ksr_request_route</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(114,115,122)">msg</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== request - from kamailio python \
script</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>        KSR.setdsturi(<span \
style="color:rgb(106,135,89)">&quot;<a \
href="http://sip:alice@127.0.0.1:5080">sip:alice@127.0.0.1:5080</a>&quot;</span>)<br> \
KSR.tm.t_on_branch(<span \
style="color:rgb(106,135,89)">&quot;ksr_branch_route_one&quot;</span>)<br>        \
KSR.tm.t_on_reply(<span \
style="color:rgb(106,135,89)">&quot;ksr_onreply_route_one&quot;</span>)<br>        \
KSR.tm.t_on_failure(<span \
style="color:rgb(106,135,89)">&quot;ksr_failure_route_one&quot;</span>)<br>        \
KSR.sl.send_reply(<span style="color:rgb(104,151,187)">100</span><span \
style="color:rgb(204,120,50)">, </span><span \
style="color:rgb(106,135,89)">&quot;Trying&quot;</span>)<br>        <span \
style="color:rgb(204,120,50)">if </span>KSR.tm.t_relay() &lt; <span \
style="color:rgb(104,151,187)">0 </span>:<br>            KSR.sl.send_reply(<span \
style="color:rgb(104,151,187)">500</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(106,135,89)">&quot;Server error&quot;</span>)<br>       \
<span style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">1<br></span><span \
style="color:rgb(104,151,187)"><br></span><span style="color:rgb(104,151,187)">    \
</span><span style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">ksr_reply_route</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(114,115,122)">msg</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== response - from kamailio python \
script</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>        <span \
style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">1<br></span><span \
style="color:rgb(104,151,187)"><br></span><span style="color:rgb(104,151,187)">    \
</span><span style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">ksr_onsend_route</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(114,115,122)">msg</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== onsend route - from kamailio python \
script</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>        <span \
style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">1<br></span><span \
style="color:rgb(104,151,187)"><br></span><span style="color:rgb(104,151,187)">    \
</span><span style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">ksr_branch_route_one</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(114,115,122)">msg</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== branch route - from kamailio python \
script</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>        <span \
style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">1<br></span><span \
style="color:rgb(104,151,187)"><br></span><span style="color:rgb(104,151,187)">    \
</span><span style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">ksr_onreply_route_one</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(114,115,122)">msg</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== onreply route - from kamailio python \
script</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>        <span \
style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">1<br></span><span \
style="color:rgb(104,151,187)"><br></span><span style="color:rgb(104,151,187)">    \
</span><span style="color:rgb(204,120,50)">def </span><span \
style="color:rgb(255,198,109)">ksr_failure_route_one</span>(<span \
style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, \
</span><span style="color:rgb(114,115,122)">msg</span>):<br>        KSR.info(<span \
style="color:rgb(106,135,89)">&quot;===== failure route - from kamailio python \
script</span><span style="color:rgb(204,120,50)">\n</span><span \
style="color:rgb(106,135,89)">&quot;</span>)<br>        <span \
style="color:rgb(204,120,50)">return </span><span \
style="color:rgb(104,151,187)">1<br></span></pre></div><div><br></div><div>Any help \
is appreciated, thanks. <br></div><div><br></div><div><br>-- <br><div dir="ltr" \
class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">- Nigel  \
</div></div></div></div></div>



__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic