473,244 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

Python 2.3 problem with extention-embedding in multi-threaded andmulti sub-interpreter environment

I am embedding python in my C++ application. I am using Python *2.3.2* with
a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to
generate C++ to Python interface.

Now to explain it in details,
1. Python initialization [Py_Initialize()] and finalization [Py_Finalize()]
is done in the *main* thread.
2. For each new thread I create a separate sub-interpreter
[Py_NewInterpreter()].
3. Using PyRun_String("import myModule"...) before execution of python
script, extention module
is imported.
4. Each thread executes *multiple* python script using PyEval_EvalCode()
using the class objects in
my extention DLL.
5. Each sub-interpreter is destroyed [Py_EndInterpreter()] at the end of
that particular thread.

I am observing that;
As explained above when multiple threads are running. And as one of these
threads finishes, in other running threads I start getting
"TypeError: 'NoneType' object is not callable" error on the methods called
on class objects in extention module.

The same code *works fine* with Python 2.2.2.

I have found these links more or less talking about the same problem
migrating from 2.2 to 2.3.
http://mail.python.org/pipermail/pyt...er/038237.html
http://mail.python.org/pipermail/pyt...ry/206851.html
http://mail.python.org/pipermail/pyt...ry/204040.html

I *guess* what is happening is global variables are zapped to "NoneType"
when one thread finishes and other thread trying to access them through the
Python script (step 4.) this error is generated. But it *works* sometimes
when(*guess*) the running thread is at step 3. and by importing the module
the global variables are re-initialized for "Type" information.

I tried using reload(myModule) to solve the problem but that is generating
big memory leak every time it is called.

Is this a know issue with 2.3 (interpreter?) ? Or is there a change for 2.3
in the way embedding should be done in a multi-threaded and
multi-sub-interpreter environment ?

Anybody for help ?
Thanks,
Atul
Jul 18 '05 #1
0 1811

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: | last post by:
Hello! Always I get many help form "comp.lang.python" I am developing appl. with pyfltk extention.(fltk extention module) as a gui toolkit. To handle network event , gui event and others, I...
3
by: Jess Martin | last post by:
i need help. im just learning to program and every time i try to do a command more than a line long it wont work _________________________________________________________________ Get less junk...
1
by: MFA | last post by:
Hi all I have installed Front page server Extention on IIS 5.0 it was working fine. I was able to load project from Visual Interdav and doing well. Yesterday I installed a security update from...
17
by: bearophileHUGS | last post by:
Hello, I know this topic was discussed a *lot* in the past, sorry if it bores you... >From the Daily Python-URL I've seen this interesting Floating Point Benchmark:...
1
by: praba kar | last post by:
Dear All, Python 2.3 creates byte code with *.pyc extention. But Python 2.4 creates bytes code with *.pyo. Is there any difference between *.pyc and *.pyo?. Actually After python compiled...
3
by: Tuvas | last post by:
I am currently writing an extention module that needs to recieve a list of characters that might vary in size from 0 to 8. This is written as a list of characters rather than a string because it's...
5
by: Yoshitha | last post by:
Hi I am developing a C#.Net windows application for my project. In that project I have an IDE to work on. The application is similar to Adobe Photoshop. My requirement is as follows. 1) I must...
5
by: brokow | last post by:
I was lucky to find Milton L. Hankins' Python 1.5 port of gdbm.pyd on the web a while ago, but I was wondering if there is one that works with a more recent version of Python? (For me, that one...
2
by: Jeff Rush | last post by:
While I have a reasonable understanding of the differences in new-style versus old-style classes, tonight while working a C extension module I realized I don't know how to indicate which style my C...
122
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.