[Python-Dev] Signals, threads, blocking C functions

Gustavo Carneiro gjcarneiro at gmail.com
Mon Sep 4 15:48:54 CEST 2006


On 9/4/06, Michael Hudson <mwh at python.net> wrote:
> "Gustavo Carneiro" <gjcarneiro at gmail.com> writes:
>
> > According to [1], all python needs to do to avoid this problem is
> > block all signals in all but the main thread;
>
> Argh, no: then people who call system() from non-main threads end up
> running subprocesses with all signals masked, which breaks other
> things in very mysterious ways.  Been there...

  That's a very good point; I wasn't aware that child processes
inherited the signals mask from their parent processes.

> No time to read the rest of the post, maybe in a few days...

  Don't worry.  From the feedback received so far it seems that any
proposed solution has to wait for Python 2.6 :-(

  I am now thinking of something along these lines:

typedef void (*PyPendingCallNotify)(void *user_data);
PyAPI_FUNC(void) Py_AddPendingCallNotify(PyPendingCallNotify callback,
void *user_data);
PyAPI_FUNC(void) Py_RemovePendingCallNotify(PyPendingCallNotify
callback, void *user_data);

  Regards.


More information about the Python-Dev mailing list