[pygtk] PyGTK and threading
Walter Leibbrandt
walter at translate.org.za
Mon Aug 18 15:37:26 WST 2008
Vláďa wrote:
> ... I'm absolutely new to threads, I understand what are they good for, but unfortunately I have
> almost no idea about the consequences and the problems they bring. ...
>
Seeing as you're "absolutely new to threads", I'll just make sure that
you are aware of the inherent limitations of threading in Python. But
seeing as you've read a few tutorials/articles, you probably have come
across the plight on parallelism in Python: the GIL (Global Interpreter
Lock). Basically what that implies is that, even though multi-threading
is still possible, you won't gain much in the way of performance (the
Python interpreter can still only execute one command at a time). I've
read somewhere (can't remember where... possibly a blog) that Python
threading is basically only useful for getting around blocking
situations, like waiting for input.
Besides the GIL, it is very clear that Gtk+ itself was not designed to
be used in multi-threaded applications. This has become obvious to me
after trading in Gtk# for PyGtk and realizing that the exact same
problems exist. That said, you might want to take a look at
http://www.mono-project.com/Responsive_Applications. Although that
article is written for use with Gtk#, the (supported) concepts are the
same for PyGtk.
Personally, I have not tried to multi-thread an app with PyGtk, but I
can assure you that it was a mess with Gtk#. :P
Good luck!
Walter
--
Walter Leibbrandt http://translate.org.za/blogs/walter
Software Developer +27 12 460 1095 (w)
Translate.org.za
Recent blogs:
* Auto-completion and auto-correction for Gtk+ widgets
http://www.translate.org.za/blogs/walter/en/content/auto-completion-and-auto-correction-gtk-widgets
* Gtk+ Tip of the Day: Modifying the subject of an event being processed
* Spelt 0.1rc2 released
More information about the pygtk
mailing list