Keyboard interrupts, Idle vs. SciTE

J

John Ladasky

Hi there.

The following minimal code in Python 2.3.4 works under Idle v. 1.0.3,
but not under SciTE v. 1.66:

from time import sleep
try:
while True:
sleep(0.25)
print ".",
except KeyboardInterrupt:
print "\nKeyboard interrupt received. Exiting program.\n\n"


Under SciTE, I do not get my "exiting program" message. Instead, I get
the standard SciTE abort message:

Process failed to respond; forcing abrupt termination...
Exit code: 1


I much prefer the SciTE environment to Idle. Is there any way that I
can rewrite my program to restore the keyboard interrupt function under
SciTE? Alternately, is there some setting that I can change in SciTE
to accomplish the same effect?

Thanks for your input!


+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Ladasky Home Solar, Inc.: blowing sunshine up your |
| power grid since March 24, 2005. Fiat lux! |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Uptime Downtime kWh generated kWh consumed |
| 584 days 6.5 hours 10953 10982 |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
 
N

Neil Hodgson

John Ladasky:
Under SciTE, I do not get my "exiting program" message. Instead, I get
the standard SciTE abort message:




I much prefer the SciTE environment to Idle. Is there any way that I
can rewrite my program to restore the keyboard interrupt function under
SciTE? Alternately, is there some setting that I can change in SciTE
to accomplish the same effect?

This is on Windows - its generally a good idea to say which platform
you are using. SciTE runs Python as an external process and tries to
interrupt by writing a Ctrl+Z to the input of the running process which
works for many interactive programs. If that fails, it calls
TerminateProcess and displays the message you see.

There is some dead code to call
GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT... in scite/src/SciTEWin.cxx
that you could try to enable and rebuild SciTE.

Idle may be running the code in-process but even if it is running it
out of process in debugging mode, it still has much more knowledge of
the execution environment. SciTE uses the same code for running Python
as for running grep or javac.

Neil
 
R

robert

John said:
Hi there.

The following minimal code in Python 2.3.4 works under Idle v. 1.0.3,
but not under SciTE v. 1.66:

from time import sleep
try:
while True:
sleep(0.25)
print ".",
except KeyboardInterrupt:
print "\nKeyboard interrupt received. Exiting program.\n\n"


Under SciTE, I do not get my "exiting program" message. Instead, I get
the standard SciTE abort message:




I much prefer the SciTE environment to Idle. Is there any way that I
can rewrite my program to restore the keyboard interrupt function under
SciTE? Alternately, is there some setting that I can change in SciTE
to accomplish the same effect?

Use PythonWin on Windows. It is based on the same Scintilla editor, but provides real interaction and inline script execution capabs, debugging ...
SciTE catches only stdout ( sometimes :) ) etc.

robert
 
J

John Ladasky

Thanks for the SciTE info, Neil.

Yes, it was silly of me to forget to state that I'm using Win32.
Normally, when I post to comp.lang.python, I remember to include that
fact... :^P

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Ladasky Home Solar, Inc.: blowing sunshine up your |
| power grid since March 24, 2005. Fiat lux! |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Uptime Downtime kWh generated kWh consumed |
| 584 days 6.5 hours 10953 10982 |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
 
J

John Ladasky

Thanks Robert, I just poked around and found a PythonWin web page:

http://aspn.activestate.com/ASPN/docs/ActivePython/2.3/pywin32/html/pythonwin/readme.html
From other links it appears that SciTE was based on PythonWin, and not
the other way around. For people coding in other languages besides
Python, switching from SciTE to PythonWin might be a step backward.
But probably not for me. I'll give it a try.

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Ladasky Home Solar, Inc.: blowing sunshine up your |
| power grid since March 24, 2005. Fiat lux! |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Uptime Downtime kWh generated kWh consumed |
| 584 days 6.5 hours 10953 10982 |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top