Will python ever have signalhandlers in threads?

Antoon Pardon apardon at forel.vub.ac.be
Mon Nov 15 02:22:07 EST 2004


On 2004-11-12, Bengt Richter <bokr at oz.net> wrote:
> On 9 Nov 2004 11:56:32 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>
>>I have had a look at the signal module and the example
>>and came to the conclusion that the example wont work
>>if you try to do this in a thread.
>>
>>So is there a chance similar code will work in a thread?
>>
> Do you have a specific use in mind?

Any code that can block/run for unbounded time (in extention code)
and you wish to interrupt after a certain time out.

One thing where it could be usefull is the Queue module.

AFAIU the Queue module doesn't block on a full/empty queue when
a timeout is specified but goes in a loop sleeping and periodically
checking whether place/items are available. With signals that
can be sent to a thread the queue could just set an alarm and
then block as if no timeout value was set and either unblock
when place/items are available or get signalled when the timeout
period is over.

-- 
Antoon Pardon



More information about the Python-list mailing list