
On Sep 16, 2:11 am, "Gregory P. Smith" <g...@krypto.org> wrote:
On Tue, Sep 15, 2009 at 4:31 PM, ryles <ryle...@gmail.com> wrote:
On Sep 15, 3:45 pm, Mike Meyer <mwm-keyword-python.b4b...@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():
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(): time.sleep(1) Often this represented as a wait() method of thread objects themselves.