[Python-ideas] IDEA: do not alter default SIGINT handling

ryles rylesny at gmail.com
Wed Sep 16 18:01:47 CEST 2009

On Sep 16, 2:11 am, "Gregory P. Smith" <g... at krypto.org> wrote:
> On Tue, Sep 15, 2009 at 4:31 PM, ryles <ryle... 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.)

I usually tend towards something simple like:

while thread.is_alive():

Often this represented as a wait() method of thread objects themselves.

More information about the Python-ideas mailing list