<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<span style="color: black; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">Hi,</span><br>
</div>
<div>
<div id="Signature">
<div class="x_container" style="max-width:900px">
<div class="x_row" align="left" style="padding-top:15px; font-family:Source Sans Pro,sans-serif; font-size:14px; padding-bottom:10px">
<div style="font-size:15px;font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, "system-ui", Roboto, "Helvetica Neue", sans-serif;margin:0px;color:rgb(36, 36, 36);text-align:start;background-color:rgb(255, 255, 255)">
<div style="font-size:12pt;font-family:Calibri, Arial, Helvetica, sans-serif;margin:0px;color:black">
our python configuration consists of many files, too. To have the reload working, we have this block in our configuration:<br>
</div>
<div style="margin:0px">
<div style="margin:0px;max-width:900px">
<div style="margin:0px">
<p style="margin-top:0px;margin-bottom:0px"><br class="ContentPasted0">
</p>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">import mod1</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">import mod2</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">import mod3</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">from importlib import reload</span><br class="ContentPasted0">
</div>
<div style="margin:0px"><br class="ContentPasted0">
</div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">def mod_init():</span>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">    KSR.info("===== initializing kamailio.py\n")</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">    reload(mod1)</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">    reload(mod2)</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">    reload(mod3)</span></div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">    KSR.info("===== Done reloading modules\n")</span></div>
</div>
<div style="margin:0px"><span style="font-family:"Courier New", monospace;margin:0px" class="ContentPasted0">    return kamailio()</span><br class="ContentPasted0">
</div>
</div>
<div align="left" style="font-size:14px;font-family:"Source Sans Pro", sans-serif;margin:0px;padding:15px 0px 10px">
</div>
<div align="left" style="font-size:14px;font-family:"Source Sans Pro", sans-serif;margin:0px;padding:15px 0px 10px">
<span style="font-size: 12pt; margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);" class="ContentPasted0">​</span><span style="font-size: 12pt; margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);" class="ContentPasted0">modX
 will be the modules you import at the top.</span><br class="ContentPasted0">
</div>
<div align="left" style="font-size:14px;font-family:"Source Sans Pro", sans-serif;margin:0px;padding:15px 0px 10px" class="ContentPasted0">
<span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(36, 36, 36); background-color: rgba(0, 0, 0, 0);">HTH<br>
</span></div>
<div align="left" style="font-size:14px;font-family:"Source Sans Pro", sans-serif;margin:0px;padding:15px 0px 10px" class="ContentPasted0">
<span style="background-color: rgba(0, 0, 0, 0); color: rgb(36, 36, 36); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">Sebastian</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org> on behalf of Niklas Larsson <niklas@tese.se><br>
<b>Sent:</b> Monday, November 14, 2022 10:46<br>
<b>To:</b> Henning Westerholt <hw@gilawa.com>; Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org><br>
<b>Subject:</b> Re: [SR-Users] KEMI - app_python3 - reload multiple python files</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi,<br>
<br>
that is what we do:<br>
<br>
import sys<br>
import KSR as KSR<br>
import constants<br>
import endpointparam as epParam<br>
import iendpoint as ep<br>
from util import ParseAddress<br>
from endpoint import GetEgressEndPointInstance, CreateAsteriskEndPoint, <br>
CreateSipTrunkEndPoint<br>
<br>
etc<br>
<br>
Been googling a bit, and it's should be possible to do a module.reload() <br>
- but is there a way to find out in that the modules needs to be reloaded?<br>
<br>
/niklas<br>
<br>
Den 2022-11-14 kl. 09:05, skrev Henning Westerholt:<br>
> Hello,<br>
><br>
> have you tried to just use "import my-file" the file my-file in your kamailio.py?<br>
><br>
> Cheers,<br>
><br>
> Henning<br>
><br>
<br>
__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
sr-users@lists.kamailio.org<br>
Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
Edit mailing list options or unsubscribe:<br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div>
</span></font></div>
</body>
</html>