Will python ever have signalhandlers in threads?

Antoon Pardon apardon at forel.vub.ac.be
Fri Nov 19 04:05:23 EST 2004


On 2004-11-19, Tim Peters <tim.peters at gmail.com> wrote:
> ...
>
> [Antoon Pardon]
>> Sure but that is not enough is it? The work for letting one thread
>> raise an exception in an other thread is done.
>
> Are you talking about the internal PyThreadState_SetAsyncExc gimmick? 
> If so, that's got nothing to do with signals.  If that's all you want,
> say so, and leave signals out of it.

I'm talking about PyThreadState_SetAsyncExc only as a throw in
response to your previous remark. The main subject is signals.

> As to whether the work is done, emphatically no, it isn't.  I hadn't
> looked at its implementation before, so just did.  That uncovered a
> critical bug "by eyeball", which may delay the release of Python 2.4. 
> Happy now <wink>?

Well wether the work is done or not hardly seems to matter. The
documentation as worded now seems to make it clear, this isn't
going get into the language 

> Seriously, that's just an error in the C coding.  The work for a
> Python-level feature hasn't even begun.  I'd guess it's about 5% of
> the way there (believe it or not, writing C code is typically the
> least time-consuming part of any language feature).

As I understand the doc, one doesn't plan to begin working on a
Python-level feature and even if someone else implements it, it
has no chance of getting in the language. As I read the docs it
is not so much a question of the feature not being ready for the
langauge, but a question of Guido not wanting the feature to be
in the language.


This just to show that having someone implement it, is not
the biggest hurdle as your prevous remark seemed to suggest
to me.

But that is enough of this tangent (although I did find your
remarks about it interesting)

>> To be more specific, the documentation of the signal
>> module states the following.
>> 
>>   ... only the main thread can set a new signal handler, and the main
>>   thread will be the only one to receive signals (this is enforced by
>>   the Python signal module, even if the underlying thread implementa-
>>   tion supports sending signals to individual threads).
>> 
>> The question I have is the following. That the main thread is the only
>> one to receive signals, is that purely implemented in the signal module
>> or is there some interpreter magic that supports this, which can
>> cause problems for an alternative signal module.
>
> Read the code?  As I said before, I pay no attention to the signal
> module, and the only way I could answer these questions is by studying
> the code too.  Maybe someone else here already knows, and will chip
> in.

Well I'll wait a few days to see if someone does, otherwise I'll see
I can find enough time to dive into the code.


Although you can't help me with my main question, I like to express
my appreciation for your responses. They have been very insighfull
and I'll be sure to use them to my advantage.

-- 
Antoon Pardon



More information about the Python-list mailing list