Python Embedding Questions

Sean Ryan searyan at gmail.com
Tue Aug 1 09:46:30 EDT 2006


Hi Guys,

I have a couple of questions (and some concerns) about embedded python
within my application.

The application is a multi-threaded relatively complex c++ middleware
Solaris 9 based application.  A decision was made some time ago to provide
some scripting capabilities and python was selected as the scripting
language.  As such,  an interpreter was embedded within the application and
threading was managed using PyEval_SaveThread, PyEval_RestoreThread and
friends.

The application switches between python and c++ many, many times during the
execution of one business request - typically the flow will be

c++ -> python -> c++ -> python -> c++ -> python etc (roughly 60 - 40 split
in terms of coverage)

Originally python2.2.1 was embedded within the application - we now have a
business case (performance being a primary driver) to move to python2.4(.2).


We are having some stability issues (random core dumps), and in an attempt
to track down the root cause I executed some stress tests under a purify
environment and noticed the following :

Python2.4.2 trips quite a few ABR (array bounds read) and FMR (free memory
read) violations - python2.2.1  less so.
     purify notes the following as the innermost frames for a FMR.
     frame_dealloc  [frameobject.c:76]
     PyEval_EvalCodeEx [ceval.c:2596]
     fast_function  [ceval.c:3161]

Is this a known issue with embedded python?

I can trigger a similar crash with python 2.2.1 in a stress test
environment.

At this stage, I am getting very concerned about our implementation of
embedded python and wondered :

1.  Is our use of python as an embedded language commonplace?
2.  Does anyone have names of commerical applications that use python in
this way
3.  Are we switching between python and c++ code too frequently (as many as
40 times in the execution of 1 request)
4.  Are there any consultants / contractors that we could engage to aid
debugging our application / implementation.
5.  Are the warnings that purify is raising related to loss of stability in
the application
6.  Is python the correct choice for an embedded application (I am aware of
the GIL issue)

We need to make a concise decision very quickly regarding our use of python,
and as such would appreciate the community's honest opinion.

Best regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060801/3571368c/attachment.html>


More information about the Python-list mailing list