[Python-Dev] Signals+Threads (PyGTK waking up 10x/sec).
"Martin v. Löwis"
martin at v.loewis.de
Sat Dec 8 19:09:12 CET 2007
> According to , all python needs to do to avoid this problem is
> block all signals in all but the main thread; then we can guarantee
> signal handlers are always called from the main thread, and pygtk
> doesn't need a timeout.
>  https://bugzilla.redhat.com/bugzilla/process_bug.cgi#c3
> Unfortunately I can't read  without having registered, so I can
> only guess what it says. But I know that Python already ensures that
> signals are only delivered to the main thread. What am I missing?
Your notion of "delivers" differs. Python does receive signals in
threads other than the main thread. However, it will only invoke the
*Python* signal handler in the main thread.
signalmodule.c:signal_handler calls Py_AddPendingCall, which is
only ever considered in the main thread (although perhaps not
in a timely manner - this is precisely where the busy-waiting in gtk
Python does not attempt to block any signals, let alone using
More information about the Python-Dev