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



Op 12-01-12 19:39, Richard Procter schreef:
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.
Small correction, it should be gobject.threads_init()

Cheers,
Timo


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.
_______________________________________________
python-hackers-list mailing list
python-hackers-list gnome org
http://mail.gnome.org/mailman/listinfo/python-hackers-list



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