On May 18, 9:28 am, Christoph Scheingraber <s...@scheingraber.net> wrote: > 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 next data download > {it's a for-loop})? > > I have tried it, but after catching the KeyboardInterrupt I could only > continue to the next iteration.
No, since the exception being raised represents a different flow of control through the program, one that is mutually exclusive with the flow of control which would be involved with continuing the processing in the "current" iteration of your loop. Setting SA_RESTART on SIGINT is probably the right thing to do. It's not totally clear to me from the messages in this thread if you managed to get that approach working. The most commonly encountered problem with this approach is that it means that any blocking (eg I/O) operation in progress won't be interrupted and you'll have to wait for it to complete normally. In this case, it sounds like this is the behavior you actually want, though. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list