[Python-Dev] Problem with signals in a single threaded application

Ulisses Furquim ulissesf at gmail.com
Sun Jan 28 02:18:00 CET 2007


On 1/27/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > Why not?
>
> Correct me if I'm wrong, but what I got from the OP
> was that the current method does
>
>    if (is_tripped) {
>      for each signal {
>        if the signal has occurred, call its handler
>      }
>      is_tripped = 0;
>    }
>
> and the problem is that any setting of is_tripped that
> occurs in the midst of calling the handlers gets
> wiped out at the end.
>
> Changing this to
>
>    while (is_tripped) {
>      for each signal {
>        if the signal has occurred, call its handler
>      }
>      is_tripped = 0;
>    }
>
> doesn't solve that, because is_tripped still gets
> set to 0 before it's tested again.

Agreed.

> Thinking about it more, probably it doesn't. What's
> important is to clear it *before* testing whether any
> handlers need to be called, i.e.
>
>    if (is_tripped) {
>     is_tripped = 0;
>     for each signal {
>        if the signal has occurred, call its handler
>      }
>    }
>

That's exactly what my patch does as you can see here:

http://www.python.org/sf/1643738

Regards,

-- Ulisses


More information about the Python-Dev mailing list