David Bolen db3l at
Fri Jul 20 19:07:24 EDT 2001

ransen_spam_me_not at (Owen F. Ransen) writes:

> The Quick Python Book says that KeyboardInterrupt is
> tested regularly when the Python interpreter is running,
> but I have a program which may run for several minutes
> without printing anything, and I find I cannot break out of
> it with control-C.
> How can I get my program to be more responsive to control-C?

Are you by any chance writing code that tends to have catch-all
"except" clauses?

If so, then the KeyboardInterrupt might be getting swallowed by one of
those (or require you to hit Ctrl-C more than once to get past one or
more exception handlers and then actually terminate the application).

Or, if you have a top level application exception clause that is
intended to help keep the application running even in unexpected
circumstances, you may need to special case KeyboardInterrupt and
terminate or re-raise it to terminate.

-- David
 \               David Bolen            \   E-mail: db3l at  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list