[review] Re: [PyKDE] Embedded python

Jim Bublitz jbublitz at nwinternet.com
Thu Jun 3 04:25:01 BST 2004


On Wednesday 02 June 2004 09:33, Kevin Schmidt wrote:
> 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?

I found this article today, which has a pretty good (although slightly dated) 
explanation of embedding and threading:

http://www.linuxjournal.com/article.php?sid=3641

Jim




More information about the PyQt mailing list