[review] Re: [PyKDE] Embedded python
Kevin Schmidt
kevin at eyesopen.com
Wed Jun 2 18:33:00 BST 2004
Hmm.. so in an effort to check to ensure things were thread safe, I've
put in a bunch of thread blocking stuff. Around all code that calls to
python, I call Py_BLOCK_THREADS and Py_UNBLOCK_THREADS. The problem
this yields is that when it hits the PyQt stuff, it hangs, trying to get
the GIL.
I guess I'm wondering if I'm doing something dramtically wrong here?
Basically, what I have now is, in my constructor, I call:
Py_Initialize();
PyEval_InitThreads();
_interp = PyInterpreterState_New( );
_save = PyThreadState_New(_interp);
At the end of it, I call Py_UNBLOCK_THREADS
Then, I wrap all Python calling code as stated above. Suggestions?
Kevin
David Boddie wrote:
> On Wed Jun 2 15:28:00 2004, Kevin Schmidt kevin at eyesopen.com wrote:
>
>
>>However, if I try:
>>
>>from qt import *
>>q=QObject()
>>p=QObject(p)
>>print p.parent()
>>
>>It crashes when I try to compile (via Py_CompileString(c_line, "",
>>Py_single_input)) the "print p.parent()" line.
>
>
> I would have thought that the string "print p.parent()\n" would compile
> without any problems, since the compiler only cares about the syntax used,
> not whether the objects mentioned behave in the way you expect. The
> problems should occur when you try to execute the code object returned
> by Py_CompileString.
>
> Can you post an excerpt from your C code where you do this, or try to
> collect some error messages using the PyErr_Print() function?
>
> Without knowing more about the environment you are running the interpreter
> in, or seeing any debug output, it is difficult to diagnose the problem you
> are seeing.
>
> David
More information about the PyQt
mailing list