[gst-devel] Threads and gst-python

Johan Dahlin johan at fluendo.com
Wed Oct 20 06:59:03 CEST 2004


> (As far as I know, there's no separate list for gst-python, please let
> me know if I'm wrong).

No, not at this point. Should be fine in here.

> So, this week I updated my CVS copy of gst-python, just to notice that
> it now requires the shiny new PyGTK 2.4. The other thing I noticed is
> that it breaks my application badly :-(

Yeah, I upped the requirements, because its simple too much trouble
dealing with unstable versions of PyGTK.

> Investigating a bit more into the problem, pointed me directly to the
> usual suspect: my app (a DVD player written mainly in Python) creates a
> number of GStreamer threads which in turn emit signals that are being
> handled in Python (i.e. Python procedures/methods are being connected to
> the signals). As soon as one of those threads emits a signal, the
> program dies with a segmentation fault.

(Note: I'm both the maintainer of gst-python and PyGTK)

We have exactly the same problem in flumotion, to be able to deal with
it, we needed to have the new PyGIL ThreadState API that was introduced
in Python 2.3. However, this interface is slightly broken, so
applications using the python thread module simple stops working, which
is quite unacceptable for a project like PyGTK. So in the last minute we
disabled usage of the new API, unless you set the environment variable
PYGTK_USE_GIL_STATE_API to something.
The real bug is a python bug and is fixed in both the maintainer (2.3.x)
and upstream, so when the next version is released we can remove this
hack and make the behavior the default.
This is not really documented, since it's still quite unstable. So make
sure not to use the "thread" or "threading" module in your application.
Having threads from C code (eg GstElements) that emit signals from other
threads should work, our server depends on this.

Can you try setting the environment variable and see if it works better
for you?

Btw, it's really cool that someone else is writing applications using
gst-python. Rock on!

-- 
Johan Dahlin <johan at fluendo.com>
Fluendo S.L.





More information about the gstreamer-devel mailing list