[Python-ideas] IDEA: do not alter default SIGINT handling
Gregory P. Smith
greg at krypto.org
Wed Sep 16 08:11:34 CEST 2009
On Tue, Sep 15, 2009 at 4:31 PM, ryles <rylesny at gmail.com> wrote:
> On Sep 15, 3:45 pm, Mike Meyer <mwm-keyword-python.b4b... at mired.org>
> wrote:
>> Is there an example in the standard library that doesn't handle
>> interrupts properly on both systems?
>
> The one that often annoys people in the standard library is
> threading.Thread.join():
>
> http://bugs.python.org/issue1167930
Another work around is to do absolutely nothing in your main program
thread other than sit in:
while not_time_to_exit:
time.sleep(9999999)
The main thread handles all signals. Move the rest of your work
(including joining, etc) to other threads. Have one of them set
not_time_to_exit and send a signal to yourself to cause the sleep to
exit. (or instead of sleep, open a pipe and poke the pipe by writing
some data to it to indicate its time to exit vs loop again, etc.)
More information about the Python-ideas
mailing list