Re: connect SIGINT to custom interrupt handler

2011-05-18 Thread Christoph Scheingraber
On 2011-05-15, Miki Tebeka miki.teb...@gmail.com wrote: Why not just catch KeyboardInterrupt? Would it be possible to continue my program as nothing had happened in that case (like I did before, setting a flag to tell main() to finish the running data download and quit instead of starting the

connect SIGINT to custom interrupt handler

2011-05-15 Thread Christoph Scheingraber
Hi, I am trying to connect SIGINT (^c) to a custom interrupt handler like this (no threading, just straightforward): if __name__ == __main__: quit = False def interrupt_handler(signal, frame): global quit if not quit: print blabla, i'll finish my task and quit kind of message

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Christoph Scheingraber
+, Christoph Scheingraber wrote: signal.signal(signal.SIGINT, interrupt_handler) This worked fine in some rare lucky cases, but most of the times, the module I am using (my university's seismology project) catches the SIGINT and quits: select.error: (4, 'Interrupted system call') After

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Christoph Scheingraber
On 2011-05-15, Thomas 'PointedEars' Lahn pointede...@web.de wrote: Obviously. `signal' refers to an `int' object, probably by something like signal = 42 before. E.g. `print' or a debugger will tell you, as you have not showed the relevant parts of the code. The problem is that I am