Re: KeyboardInterrupt exception

2009-01-05 Thread Daniel Kersten
My app is single threaded, so this may work. I'll give it a shot. 2009/1/5 Steve McConville : > > Don't have time to test it, but maybe a simpler approach would be to > explicitly replace the default SIGINT handler with something that > doesn't throw a KeyboardInterrupt? I believe it's possible t

Re: KeyboardInterrupt exception

2009-01-05 Thread Steve McConville
Don't have time to test it, but maybe a simpler approach would be to explicitly replace the default SIGINT handler with something that doesn't throw a KeyboardInterrupt? I believe it's possible to register a signal handler that will intercept them asynchronously, something like import signal si

Re: KeyboardInterrupt exception

2009-01-05 Thread Daniel Kersten
Yes exactly. My script is used to process large data files. What got me trying to do this in the first place was that after processing maybe 20k items, the script starts to misbehave (well, at least, it stops updating the summary text like it should...) so I wanted to embed pdb to have a look what

Re: KeyboardInterrupt exception

2009-01-05 Thread Aoife Hughes
Hi Daniel, I have to admit to just being a python dabbler (I've not used it for hugely serious projects), but when you hit the exception, you'll still have your state available to you via locals() Just playing around: >>> def blah(): ... try: ... a = 5 ... raise Excep

Re: KeyboardInterrupt exception

2009-01-05 Thread Michael Twomey
True, I'd forgotten about this completely. If you have a main loop which dispatches calls to functions then you can handle the exception in the function call, optionally poke at with a debugger and then continue on with the main loop (having let that individual call fail). There's a certain level

Re: KeyboardInterrupt exception

2009-01-05 Thread Daniel Kersten
Padraig, thats kinda what i figured. Pity. Michael, yes, for what I'm doing now, thats actually perfect. I was hoping to be able to use this to add other things to my menu too, besides pdb. Luckily I only need pdb for what I'm working on right now, so I'll worry about it when I actually need it.

Re: KeyboardInterrupt exception

2009-01-05 Thread Padraig Kitterick
Daniel Kersten wrote: > My code is something like this: > > while not_done: > try: > code() > except keyboardinterupt: > print "Menu:" > print " debug- run pdb" > print " resume - resume program" > print " abort - abort program" > .

Re: KeyboardInterrupt exception

2009-01-05 Thread Michael Twomey
This sounds like you are getting into the fun depths of unix signal handling, http://docs.python.org/library/signal.html One point of relevance on that page: "When a signal arrives during an I/O operation, it is possible that the I/O operation raises an exception after the signal handler returns.

Re: KeyboardInterrupt exception

2009-01-05 Thread Daniel Kersten
My code is something like this: while not_done: try: code() except keyboardinterupt: print "Menu:" print " debug- run pdb" print " resume - resume program" print " abort - abort program" ... command = raw_input("> ")

Re: KeyboardInterrupt exception

2009-01-05 Thread Ajurna
hi, it might be me and im getting this wrong but surely you could use a try: except clause? try: codeloop() except keyboardinterupt: mainloop() or something to that effect. On Mon, Jan 5, 2009 at 3:38 PM, Daniel Kersten wrote: > > Hi & happy new year, > > I'm wondering if theres a