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. This is dependent on the
underlying Unix system's semantics regarding interrupted system
calls."

You could install your own signal handler, but you'd still get this problem.

Have you considered simply using "python -m pdb myscript"? Ctrl+c will
drop into the debugger which allows you to quit or resume.

I think it essentially uses sys.excepthoook to call settrace, so you
could use your own there.

mick

On Mon, Jan 5, 2009 at 15:38, Daniel Kersten <[email protected]> wrote:
>
> Hi & happy new year,
>
> I'm wondering if theres anyway of resuming after a KeyboardInterrupt
> exception, if I catch it. For example, can I retrieve the code object
> or stack or something from when execution was interrupted and continue
> from there.
>
> Basically, I would like to use Ctrl-C as a way to temporarily break
> out of my program to enter a menu (in this particular case, the menu
> allows you to quit, continue and enter pdb). This works fine in most
> cases, but if I interrupt in the middle of certain operations, when I
> resume, I lose data. Of course, I can write my code to avoid this, but
> that may not always be possible.
>
> Any ideas? Or do I need to handle the menu in a separate thread..?
>
> Thanks!
> Dan.
>
> --
> Daniel Kersten.
> Leveraging dynamic paradigms since the synergies of 1985.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Python Ireland" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ie/group/pythonireland?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to