On 12/02/2013 09:50 AM, Dan wrote:
Also, related to Hrvoje Niksic's comment, is it safe to use GDK calls
from other threads at all (as long as you guard them with the
appropriate incantations)? Or do you absolutely have to schedule all
GUI work to the GUI thread?

According to https://developer.gnome.org/gdk3/stable/gdk3-Threads.html, GDK calls from other threads are unsafe in non-X11 backends, even with locks around the calls. When using the X11 backend, the documentation warns that combining the GDK lock with other locks, such as Python's "GIL" can be complicated, and that such locking is deprecated in GTK 3.

Judging by the documentation, it seems best to keep GDK calls to a single thread, unless you only use X11 and really know what you are doing.

If the latter, then I also don't see the
point of locking in the callback.

Ah, so the point of locking in the callback would be to prevent a race condition between the GUI thread calling into GTK and other threads doing the same?

But in that case, requirement for g_idle_add callbacks locking stands for *all* calls to g_idle_add in the application (including those performed by GTK itself, if any), not only those coming from another thread. After all, whichever thread g_idle_add is called from, the callback will end up running in the same thread, the GUI thread that runs the main loop.

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to