[FRPythoneers] Re: FRPythoneers Digest, Vol 2, Issue 6

Demian demian0311 at yahoo.com
Fri Jan 23 13:18:18 MST 2004

i'm pretty sure that's one of the things you lose in Jython; keyboard interrupts.  it's a java
environment limitation.  (see page 248 in 'Jython Essentials').

> I maintain a suite of Python programs for internal use in my company. Using
> the Jython compiler, I have compiled a subset of these programs in a .jar
> file for external use.
> Generally, things have gone well, but there seem to be a few key functions
> that do not translate.
> One is the KeyboardInterrupt exception. The Python programs trap the
> KeyboardInterrupt to allow the user to enter Ctl-C to skip a step and move
> on, or in some cases, to provide an elegant, controlled exit. When compiled
> into a .jar and run under java, a Ctl-C causes the programs to exit straight
> to the command prompt. Sometimes generating an obscure java traceback.
> Does anyone have an idea how I can get around this problem and re-activate
> the Ctl-C features in the compiled code?
> Test code -
> ------------------
> from time import sleep
> try:
>     while 1:
>         print ".",
>         sleep(.2)
> except KeyboardInterrupt:
>     print "\n\n  PROGRAM INTERRUPTED\n"

Demian L. Neidetcher
demian0311 at yahoo.com

Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

More information about the FRPythoneers mailing list