[OpenSIPS-Users] python module - bug and questions

Maxim Sobolev sobomax at sippysoft.com
Fri Apr 21 11:56:43 EDT 2017


Robert, what Bogdan says is essentially correct. The OpenSIPS itself is not
using any threads AFAIK, therefore python module code is kept as simple as
possible. Now back to the original question: we use quite a lot of python
code in our routing and some of the python modules that are running are
actually creating threads on their own and it appears to be pretty stable.
What OS / python version are you using? What could be different in our case
is that we link our OpenSIPS binary with pthreads always (which may or may
not be the case on your build), so there might be some vital threads
runtime infrastructure that is not getting initialized in your case.

-Max


On Fri, Apr 21, 2017 at 1:25 AM, Bogdan-Andrei Iancu <bogdan at opensips.org>
wrote:

> Hi Robert,
>
> The only question I can answer is 1) - OpenSIPS it is a multi-process
> application (and not using threads).
>
> How the python module is design (from threading perspective), I do not
> know - maybe Maxim, the author of this module can help with this.
>
> Regards,
>
> Bogdan-Andrei Iancu
>   OpenSIPS Founder and Developer
>   http://www.opensips-solutions.com
>
> OpenSIPS Summit May 2017 Amsterdam
>   http://www.opensips.org/events/Summit-2017Amsterdam.html
>
> On 04/19/2017 08:43 PM, Mundkowsky, Robert wrote:
>
>
>
> Hi,
>
>
>
> This email should likely go to your other dev forum, but I don’t have
> access yet.
>
>
>
> I am using openSIPS 2.2.3 on Ubuntu 16.04.2 LTS.
>
>
>
> I am using the python module.  The python script called works fine when
> called from outside openSIPS and it works fine when called inside openSIPS,
> if it is triggered once at a time.
>
>
>
> But if the python script is triggered twice by two phone calls or more or
> even one call after another in short order, then there are weird errors
> which show up in different places in the code like:
>
>
>
> ERROR:python:python_handle_exception: #011TypeError: an integer is
> required
>
>
>
> I am guessing the openSIP python module has some problem/s related to
> threading.
>
>
>
>
>
> Questions:
>
> 1)      I am guessing that OpenSIPS uses a multi-threaded architecture?
>
> 2)      Is the python module meant to be a single thread? Or
> multi-threaded?
>
> a.       If it is meant to be single threaded then why use python library
> thread functions? Just use python library without multi-threaded stuff.
>
> b.      If it is meant to be multi-threaded then why is there only one
> call to PyThreadState_New and myThreadState is a global used everywhere?
>
>                                                                i.      I
> would think a thread per call to python_exec would make more sense and make
> the code easier to understand?
>
> 3)      Also why is there no clean up code (PyThreadState_Clear,
> PyThreadState_Delete, Py_Finalize)?
>
> a.       I am guessing the idea is you do not need clean up, because it
> only happens when openSIPS is turned off.
>
>
>
> Robert
>
>
>
>
>
> For reference:
>
> <https://www.codeproject.com/articles/11805/embedding-python-in-c-c-part-i>
> https://www.codeproject.com/articles/11805/embedding-python-in-c-c-part-i
>
> <http://www.awasu.com/weblog/embedding-python/threads/>
> http://www.awasu.com/weblog/embedding-python/threads/
>
>
> <http://stackoverflow.com/questions/26061298/python-multi-thread-multi-interpreter-c-api>
> http://stackoverflow.com/questions/26061298/python-multi-thread-multi-
> interpreter-c-api
>
>
>
> ------------------------------
>
> This e-mail and any files transmitted with it may contain privileged or
> confidential information. It is solely for use by the individual for whom
> it is intended, even if addressed incorrectly. If you received this e-mail
> in error, please notify the sender; do not disclose, copy, distribute, or
> take any action in reliance on the contents of this information; and delete
> it from your system. Any other use of this e-mail is prohibited.
>
> Thank you for your compliance.
> ------------------------------
>
>
> _______________________________________________
> Users mailing listUsers at lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>


-- 
Maksym Sobolyev
Sippy Software, Inc.
Internet Telephony (VoIP) Experts
Tel (Canada): +1-778-783-0474
Tel (Toll-Free): +1-855-747-7779
Fax: +1-866-857-6942
Web: http://www.sippysoft.com
MSN: sales at sippysoft.com
Skype: SippySoft
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170421/90f6a0ba/attachment.html>


More information about the Users mailing list