Re: python-hackers-list Digest, Vol 21, Issue 2



On 13/01/2012, at 1:00 AM, python-hackers-list-request gnome org wrote:
> 
> Message: 1
> Date: Thu, 12 Jan 2012 10:46:51 +0100
> From: Matthias Vogelgesang <matthias vogelgesang gmail com>
> To: python-hackers-list gnome org
> Subject: C-thread calling Python
> Message-ID:
> 	<CAOHB9GN10D_jsYD-McXGzH=PD4YB4Ro0S1nT9MyZFb9i+-USdQ mail gmail com>
> Content-Type: text/plain; charset=UTF-8
> 
> Hi,
> 
> I am facing a problem that I hope some of you could help me solve. I
> have a third-party library written in C based on GObject. This library
> exports a class that is meant to be subclassed in C or Python. After
> some initialization, a manager (written in C) creates one thread per
> instance and calls a method of this associated instance and waits
> until all calls are finished. This works fine in C and Python as long
> as the subclasses are written in C. However, if written in Python the
> method is called but execution is blocked. I guess Python's GIL is the
> root of this problem, because the interpreter is still holding the
> lock and the subclass instances are never able to acquire it.

Hi Matthias, 

This is just a guess but check that gobject.init_threads() has been called.

IIRC, without it gobject doesn't actually release and re-aquire the GIL when 
executing outside of the python interpreter. It had me puzzled for quite a
while. 

warm regards,  
Richard. 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]