[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Py_Finalize ERROR!

zaley

2/19/2008 7:11:00 AM

Py_Finalize ERROR!

In my C++ program ,python is embeded . I create one win thread to run
embedded Python code .
So at the begin of thread function I call "Py_Initialize" and at the
end of thread function call "Py_Finalize" .
But after I began thread several times,the program crashed in
function "Py_Finalize".
I can see the error occured at function "PyObject_ClearWeakRefs" when
"Py_Finalize" called "type_dealloc";

Note: the python25.dll(lib) is builded by VC6(SP6)
2 Answers

james.pye

2/19/2008 5:23:00 PM

0

On Feb 19, 12:11 am, zaley <lizhon...@gmail.com> wrote:
> Py_Finalize ERROR!
>
> In my C++ program ,python is embeded . I create one win thread to run
> embedded Python code .
> So at the begin of thread function I call "Py_Initialize" and at the
> end of thread function call "Py_Finalize" .
> But after I began thread several times,the program crashed  in
> function  "Py_Finalize".
> I can see the error occured at function "PyObject_ClearWeakRefs" when
> "Py_Finalize" called "type_dealloc";
>
> Note: the python25.dll(lib) is builded by VC6(SP6)

I think I ran into this error with my pgsql PL project--at some point.
I think I "fixed" it by *not* calling Py_Finalize(). =)

However, I'm sure a report would be welcome, so if you don't mind
going through some hassle, I'd suggest making a trip to the bug
tracker.

Gabriel Genellina

2/19/2008 7:08:00 PM

0

On 19 feb, 05:11, zaley <lizhon...@gmail.com> wrote:
> Py_Finalize ERROR!
>
> In my C++ program ,python is embeded . I create one win thread to run
> embedded Python code .
> So at the begin of thread function I call "Py_Initialize" and at the
> end of thread function call "Py_Finalize" .
> But after I began thread several times,the program crashed  in
> function  "Py_Finalize".
> I can see the error occured at function "PyObject_ClearWeakRefs" when
> "Py_Finalize" called "type_dealloc";
>
> Note: the python25.dll(lib) is builded by VC6(SP6)

Try to not call repeatedly Py_Initialize/Py_Finalize, only at the
start/end of your program. If only one thread is running Python at the
same time I *think* you don't have to do any special handling.

--
Gabriel Genellina